[英]How to Restart the app in android marshmallow when permission changed manually
I have an android application which was supporting till lollipop. 我有一个支持棒棒糖的Android应用程序。 Now I'm migrating it to support Marshmallow.
现在,我正在迁移它以支持棉花糖。
I am stuck in a case where if we manually changed the app permission in marshmallow it kills all the process. 我陷入了一种情况,如果我们在棉花糖中手动更改应用程序权限,它将杀死所有进程。
I get it as explained by @CommonsWare in similar question here . 我明白了在类似的问题由@CommonsWare作为解释在这里 。
But in my case I have to kill the app and need to restart the app. 但就我而言,我必须终止该应用程序并需要重新启动该应用程序。 Because my app each activity is dependent on previous activity some data is shared.
因为我的应用程序的每个活动都依赖于先前的活动,所以某些数据是共享的。 I just need to know when we manually change the permission is there a way our app get noticed.?
我只需要知道当我们手动更改权限时,是否有一种方法可以引起我们的应用程序的注意。
I meant any callback occurs. 我的意思是发生任何回调。 if Not is there anyway I can handle this case.?
如果不是,我可以处理此案。 Please Let me know if the question is too broad I'll update my question
请让我知道问题是否太广泛了,我将更新我的问题
Thanks in advance 提前致谢
I just need to know when we manually change the permission is there a way our app get noticed.?
我只需要知道当我们手动更改权限时,是否有一种方法可以引起我们的应用程序的注意。
Your process is terminated. 您的过程已终止。 This is indistinguishable from any other reason why your process might be terminated.
这与您的进程可能终止的任何其他原因都没有区别。
I meant any callback occurs.
我的意思是发生任何回调。
No. You get ordinary lifecycle callbacks (eg, onPause()
, onStop()
) as the user navigates over to Settings to be able to revoke the permission, but that's it. 不会。当用户导航到Settings可以撤消权限时,您会收到普通的生命周期回调(例如
onPause()
, onStop()
),仅此而已。 There is no specific callback related to losing the permission. 没有与丢失许可相关的特定回调。
Also note that the user could leave your app, your process could be terminated for other reasons, the user could then go into Settings and revoke your permission, then the user could return to your app. 还要注意,用户可以离开您的应用程序,由于其他原因您的进程可能会终止, 然后用户可以进入“设置”并撤消您的许可,然后用户可以返回到您的应用程序。 If all of that happens within ~30 minutes, Android will still try to rebuild the outstanding task.
如果所有这些操作都在约30分钟内发生,Android仍将尝试重建未完成的任务。 You certainly would not get a callback of any sort in this case, as your process was not running before the permission was revoked, let alone after.
在这种情况下,您肯定不会得到任何类型的回调,因为您的进程在撤销权限之前没有运行,更不用说之后了。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.