问题
In Android 10 there apply new restrictions for apps. We can no longer start an activity from background. While this may be fine for the majority of apps, it's a killing blow for voip-apps that need to show an incoming call after a push notification arrived.
According to this https://developer.android.com/guide/components/activities/background-starts there is a list of conditions that can be met to still allow opening an activity, but tbh I do not understand that fully (non-english-native here).
What I definitely know, is:
I do not have any running activity, task, backstack and the like
The app is NOT EVEN RUNNING
What I need to achieve:
- The FCM service of the app receives a push from our server and shall present the incoming call screen (over lock screen and all - just as it did with android 9 and below)
What can I do to open an activity for an incoming voip call in android 10? Over the lockscreen and all, just as a normal user would expect from a PHONE app.
Thanks in advance for any hints.
回答1:
Use a high-priority notification with a "full-screen intent". That will:
- Invoke your "full-screen intent" if the device is locked
- Otherwise, display a "heads-up" notification
来源:https://stackoverflow.com/questions/58819246/how-to-open-activity-incoming-voip-call-in-android-10