I placed below code in BroadcastReceiver and this code trigger every time when a new call arrives. But bundle not contains incoming_number. By printing out the bundle I get Bundle[{state=RINGING}] as output. and I only get this problem in new phones(>= Android 9.0)
Bundle bundle = intent.getExtras();
System.out.println("Kokp 1:- " + bundle);
String phoneNumber = bundle.getString(TelephonyManager.EXTRA_INCOMING_NUMBER);
Documentation indicates that EXTRA_INCOMING_NUMBER
is only populated if your app has the following permissions:
This extra is only populated for receivers of the ACTION_PHONE_STATE_CHANGED broadcast which have been granted the Manifest.permission.READ_CALL_LOG and Manifest.permission.READ_PHONE_STATE permissions.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.