How to Restart the app in android marshmallow when permission changed manually

天涯浪子 提交于 2019-12-10 12:13:13

问题


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.

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

Thanks in advance


回答1:


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 (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.

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.



来源:https://stackoverflow.com/questions/37437339/how-to-restart-the-app-in-android-marshmallow-when-permission-changed-manually

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