telephonymanager - Retrieve incoming call's phone number in Android -


I would like to retrieve the phone number of the incoming call and would like to do something with it

Help because I have not got any information about this where I start and how can I get phononumber?


Ok so my code looks like when I call, the custombugspect receiver catches it and the log message is printed. I can retrieve the telephone number from the bundle but! I can not get the hte customphonestate lustner to work as you can see that I have registered my customphonestate listener for receiver, but the log message has never been printed with the customphonestate listener class. What am I missing here? Is my thinking right?


& lt; Receiver Android: name = "CustomBroadcastReceiver" & gt; & Lt; Intent-Filter & gt; & Lt; Action Android: name = "android.intent.action.PHONE_STATE" /> & Lt; / Intent-Filter & gt; & Lt; / Receiver & gt; & Lt; / Application & gt; & Lt; Use-sdk android: minSdkVersion = "5" /> & Lt; Usage-permission Android: name = "android.permission.INTERNET" /> & Lt; Usage-permission Android: name = "android.permission.WRITE_CONTACTS" /> & Lt; Usage-permission Android: name = "android.permission.READ_PHONE_STATE" />
  public class CustomPhoneStateListener PhoneStateListener Extended {Personal Static Last String TAG = "CustomPhoneStateListener"; Call status change (int state, string incoming number) {log. V (tag, "we are inside !!!!!!!!!!!"); Logs. V (tag, incoming number); Switch (state) {Case Telephony Manager. CALL_STATE_RINGING: Log D. (Tag, "ringing"); break; }}  

  The public class extends BroadBoardReceiver Broadcast receiver {Personal Static Last String TAG = "CustomBroadcastReceiver"; Override public zero at @Receive (reference reference, intent to intent) {log. V (tag, "we are inside !!!!!!!!!!!"); Telephony Manager Telephony = (Telephony Manager) context.getSystemService (context.TELEPHONY_SERVICE); Custom Filter Staster CustomizerListener = New Custom FilterListener (); Telephony.listen (Custom PhoneListener, PhoneStart Listsner. LISTEN_CALL_STATE); Bundle Bundle = Intent. String phone nr = bundle.gate string ("incoming_umber"); Logs. V (tag, "phone number" + phone); }  

Use it to have a handler; One of the given arguments given to you is an incoming phone number with a string .


Comments

Popular posts from this blog

c# - How to capture HTTP packet with SharpPcap -

jquery - SimpleModal Confirm fails to submit form -

php - Multiple Select with Explode: only returns the word "Array" -