java - How to get incoming call's network(carrier) details in android -
i want incoming phone call details in android phone illustration when 1 calling android phone details of number's network(carrier) airtel vodefone , docomo etc, using method getting details not carrier details
public string[] callduration(){ string callername="",type=""; cursor managedcursor = null; int number = 0,name,duration = 0,calltype = 0,date = 0; uri contacts; seek { contacts = calllog.calls.content_uri; managedcursor = mcontext.getcontentresolver().query(contacts, null, null, null, null); number = managedcursor.getcolumnindex( calllog.calls.number); name= managedcursor.getcolumnindex(calllog.calls.cached_name); duration = managedcursor.getcolumnindex( calllog.calls.duration); calltype = managedcursor.getcolumnindex( calllog.calls.type); date = managedcursor.getcolumnindex(calllog.calls.date); managedcursor.movetolast(); callername = managedcursor.getstring(name); if(callername == null){ callername = managedcursor.getstring(number); } if (managedcursor.getstring(calltype).equalsignorecase("1")) { type = "incoming"; }else if (managedcursor.getstring(calltype).equalsignorecase("2")){ type = "outgoing"; } } grab (exception e) { // todo: handle exception e.printstacktrace(); } homecoming new string[]{callername,managedcursor.getstring(number),managedcursor.getstring(duration), managedcursor.getstring(date),type}; }
official tutorial,
https://developer.android.com/reference/android/telephony/telephonymanager.html
also refer this, detecting incoming phone call coming android device
getsimoperator() -returns mcc+mnc (mobile country code + mobile network code) of provider of sim.
in manifest file,
give below permission,
< uses-permission android:name="android.permission.read_phone_state" />
< uses-permission android:name="android.permission.process_outgoing_calls"/>
java android performance android-fragments
No comments:
Post a Comment