java - How to get the number that is being dialed the , the outgoing number in android -


i keep getting value of null on outgoing number have tried couple solutions web .

in manifest have these relevant lines

 <uses-permission android:name="android.permission.read_phone_state" ></uses-permission>  <uses-permission android:name="android.permission.process_outgoing_calls" > </uses-permission>   <receiver android:name=".home.outgoingreceiver"  android:exported="true">            <intent-filter>                <action android:name="android.intent.action.phone_state" >                    <action android:name="android.intent.action.new_outgoing_call" />                  </action>            </intent-filter>        </receiver> 

my receiver looks likes , notice have been trying retrieve number in various ways here keep getting null value

public void onreceive(context context, intent intent) {         if (intent.getaction().equals(intent.action_new_outgoing_call)) {               final string originalnumber = intent.getstringextra(intent.extra_phone_number).tostring();             log.d("app", "outgoing,ringing:" + originalnumber);         }         string ph = intent.getextras().getstring(outgoingreceiver.intent_phone_number);         // savednumber = intent.getextras().getstring("android.intent.extra.phone_number");         string number = intent.getstringextra(intent.extra_phone_number);         string phonenumber = getresultdata();         if (phonenumber == null) {             // not find previous data. use original phone number in case.             phonenumber = intent.getstringextra(intent.extra_phone_number);         }         string phonenumbertest = intent.getextras().getstring(outgoingreceiver.intent_phone_number); 

first add manifest:

<action android:name="android.intent.action.new_outgoing_call" /> 

then add receiver:

if (intent.getaction().equals("android.intent.action.new_outgoing_call")) {           string outoingnumber = intent.getextras().getstring("android.intent.extra.phone_number");             return;         } 

Comments

Popular posts from this blog

Spring Boot + JPA + Hibernate: Unable to locate persister -

go - Golang: panic: runtime error: invalid memory address or nil pointer dereference using bufio.Scanner -

c - double free or corruption (fasttop) -