0

I had an app where I fetched Call Log and Contact List and showed them in a RecyclerView. Everything was going fine up to android-8. Suddenly I found that Names are not showing on an Android-9 Device. Then a debug shows that CACHED_NAME and CACHED_PHOTO_URI are always returning null on andorid-9. I get NUMBER, DURATION and every other thing very well, only the CACHED_NAME and CACHED_PHOTO_URI are missing.

I have checked the changelog of android-9, handled the calllog permission properly, I'm attaching my permissions from manifest with this question. My app is properly taking runtime permissions too. I also checked it on device's Settings. In addition, my app is also set to Default Phone app.

<uses-permission android:name="android.permission.RECEIVE_SMS" />

    <uses-permission android:name="android.permission.READ_CONTACTS" />
    <uses-permission android:name="android.permission.WRITE_CONTACTS" />
    <uses-permission android:name="android.permission.GET_ACCOUNTS" />

    <uses-permission android:name="android.permission.READ_PHONE_STATE" />
    <uses-permission android:name="android.permission.READ_PHONE_NUMBERS" />
    <uses-permission android:name="android.permission.ANSWER_PHONE_CALLS" />
    <uses-permission android:name="android.permission.CALL_PHONE" />

    <uses-permission android:name="android.permission.READ_CALL_LOG" />
    <uses-permission android:name="android.permission.WRITE_CALL_LOG" />
    <uses-permission android:name="android.permission.PROCESS_OUTGOING_CALLS" />

String number = cursor.getString(cursor.getColumnIndex(CallLog.Calls.NUMBER));
        String name = cursor.getString(cursor.getColumnIndex(CallLog.Calls.CACHED_NAME));
        Log.d("tag", "name: " + (name == null ? "null": name));
        String date = cursor.getString(cursor.getColumnIndex(CallLog.Calls.DATE));
        String duration = cursor.getString(cursor.getColumnIndex(CallLog.Calls.DURATION));
        String photoUri = cursor.getString(cursor.getColumnIndex(CallLog.Calls.CACHED_PHOTO_URI));

        Log.d("tag", "photoUri: " + (photoUri == null ? "null": photoUri));

        String subscription_id = cursor.getString(cursor.getColumnIndex(CallLog.Calls.PHONE_ACCOUNT_ID));
        String subscription_component_name = cursor.getString(cursor.getColumnIndex(CallLog.Calls.PHONE_ACCOUNT_COMPONENT_NAME));

Its working fine on android 8 and below, can anyone tell me where is the problem with android-9?

Md Tarik Mahmud
  • 331
  • 3
  • 8

2 Answers2

0

Please check that if needs RuntimePermission for CALL_LOG GROUP. Because they made some changes on Android-9

Cliff
  • 682
  • 8
  • 30
  • I checked and READ_CALL_LOG, WRITE_CALL_LOG, PROCESS_OUTGOING_CALLS are those permissions from CALL_LOG group. I am taking all these. – Md Tarik Mahmud Apr 09 '19 at 16:03
0

first, get contacts from Contacts.Contract and then get name, photo by phone number, or contact Id from the database.