Reputation: 395
I have two applications, one will send a broadcast with a customized action "com.google.android.exoplayer2.demo.action.INFORM_TIME", the other application with a broadcast receiver registered in JUnit @Before class.
This receiver works well on android Pie, but not working on android Q.
From logcat, it says "Receiving a broadcast in package xxx requires a permissions review". "xxx" stands for the JUnit test package.
adb install -g xxx
to install the two JUnit test applications on andorid Q, broadcast receiver works fine. Without -g
, not working. So it seems to be a permission issue. Application A sends broadcast:
Intent informIntent = new Intent(); informIntent.setAction("com.google.android.exoplayer2.demo.action.INFORM_TIME");
informIntent.putExtra("Time", time);
sendBroadcast(informIntent);
Application B receives broadcast:
receiver = new BroadcastReceiver() {
@Override
public void onReceive(Context context, Intent intent) {
String action = intent.getAction();
if (action != null && action.equals(ACTION_INFORM_TIME)) {
Long currentTime = intent.getLongExtra("Time", -1);
Log.d(LOG_TAG, "BroadcastReceiver: Receives current Exoplayer playback time '" + currentTime + "'.");
time = currentTime;
}
}
};
IntentFilter filter = new IntentFilter();
filter.addAction("com.google.android.exoplayer2.demo.action.INFORM_TIME");
mContext.registerReceiver(receiver, filter);
I'm not quite sure what are the differences on broadcast receiver between android Pie and android Q, between application with user visible UI and JUnit test.
The question is, what permission do we need to receive a broadcast with a customized action.
Need help, any comment will be appreciated!
Upvotes: 0
Views: 1304
Reputation: 395
Found the cause, on android Pie devices, android.permission.WRITE_EXTERNAL_STORAGE
permission works well, I can safely directly write to folder /sdcard/
. But on android Q, this won't work any more.
So this writing file failure somehow make my broadcast receiver fail to receive any broadcasts. Unbelievable!!!
Bu that's it, after I update my folder for saving files and remove the permission android.permission.WRITE_EXTERNAL_STORAGE
in manifest, broadcast receiver works fine now android Q.
Upvotes: 1