If I send an explicit BroadcastIntent that targets one specific app2, and in the BroadcastReceiver of app2, what if I'm trying to launch activities while not in foreground.
My guess is that it'll just fail. But the tests show some interesting results.
I did 2 tests that targets on Android 10:
1. App1 launches a background task that will send an explicit broadcast intent to app2 from that background task (which is launched with StartForeground so that it'll keep running even no activities in foreground). App2 has a broadcast receiver that will log and launch an activity.
I can see the logs from App2 the every broadcast sent from App1 is well-received. While launching the activities failed from time to time, but not always. I can understand if the activity cannot be launched at all due to the previously mentioned restriction, but not sure why it succeeded sometimes.
2. The same setup as in 1. But I granted SYSTEM_ALERT_WINDOW permission for App1 (which an exception to the previously mentioned restriction). In this case, the broadcasts are well-received and the activities are launched successfully.
I'm a bit confused on this case as well. If the restriction of launching activities from background task includes broadcast receiver, shouldn't App2 has that permission?