0

I have a foreground service and register a CALL_STATE receiver there. It works fine on pre Android O. Another receiver in the service works fine too. I have removed the intent filter from the manifest. I have all the correct permissions.

Is there anything else I should be doing?

In Service...

private static final String ACTION="android.intent.action.PHONE_STATE";
 registerReceiver(mCallReceiver , new IntentFilter(ACTION));
Mark Sheekey
  • 608
  • 7
  • 23
  • Just to confirm, do you hold the runtime permission for `READ_PHONE_STATE`, and not just the manifest permission? – CommonsWare Aug 25 '17 at 11:16
  • Yes, I do...... – Mark Sheekey Aug 25 '17 at 13:31
  • ..I've just double checked and I honestly thought I had the necessary permission. Seems I didnt and now everything works fine. – Mark Sheekey Aug 25 '17 at 13:46
  • 1
    OK, glad to see that it's working! – CommonsWare Aug 25 '17 at 13:49
  • 2
    Actually the "issue" was that I was asking for permission to "CALL PHONE", I thought this gave me access to READ_PHONE_STATE too. I've changed it to ask for "READ_PHONE_STATE" - the permissions text presented to the user is the same, but I now have all the necessary permission. – Mark Sheekey Aug 25 '17 at 13:59
  • Ah, OK, I misunderstood. You might want to convert that last comment into an answer, to benefit others who run across this question. – CommonsWare Aug 25 '17 at 17:38

1 Answers1

0

Actually the "issue" was that I was asking for permission to "CALL PHONE", I thought this gave me access to READ_PHONE_STATE too. I've changed it to ask for "READ_PHONE_STATE" - the permissions text presented to the user is the same, but I now have all the necessary permission.

Mark Sheekey
  • 608
  • 7
  • 23