问题描述
我有一个支持llollipop的android应用程序.现在,我正在迁移它以支持棉花糖.
I have an android application which was supporting till lollipop. 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.
我得到了@CommonsWare在类似问题中解释的>这里.
I get it as explained by @CommonsWare in similar question here.
但就我而言,我必须终止该应用程序并需要重新启动该应用程序.因为我的应用程序的每个活动都依赖于先前的活动,所以某些数据是共享的.我只需要知道当我们手动更改权限时,是否有一种方法可以引起我们的应用程序的注意.
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
预先感谢
推荐答案
您的过程已终止.这与进程可能终止的任何其他原因都没有区别.
Your process is terminated. This is indistinguishable from any other reason why your process might be terminated.
不.当用户导航到设置"以撤消该权限时,您会收到普通的生命周期回调(例如onPause()
,onStop()
),仅此而已.没有与丢失权限相关的特定回调.
No. You get ordinary lifecycle callbacks (e.g., onPause()
, onStop()
) as the user navigates over to Settings to be able to revoke the permission, but that's it. There is no specific callback related to losing the permission.
还请注意,用户可以离开您的应用,您的进程可能因其他原因而终止,用户可以然后进入设置"并撤消您的许可,然后用户可以返回您的应用.如果所有这些操作都在约30分钟内发生,Android仍将尝试重建未完成的任务.在这种情况下,您肯定不会得到任何类型的回调,因为您的进程未在之前运行,因此权限被撤消了,更不用说在之后了.
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. 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.
这篇关于手动更改权限后如何在android棉花糖中重新启动应用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!