How to start activity from service in Android10

a 夏天 提交于 2020-12-08 08:23:23

问题


I was starting activity from services till android P, but from android10 google has kept one restriction that activity cannot be started from background.

https://developer.android.com/guide/components/activities/background-starts

// below code stopped working
Intent intent = new Intent(this, MyActivity.class);
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
startActivity(intent);

what should i do for android10 ?


回答1:


You can use a notification using setFullScreenIntent, it's the best you can do or you can ask for SYSTEM_ALERT_WINDOW permission but it doesn't work with android go devices.



来源:https://stackoverflow.com/questions/57989846/how-to-start-activity-from-service-in-android10

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!