App restart when change permission in Android M?
Asked Answered
U

0

16

I am developing an android app with structure: MainActivity->FragmentA->FragmentB->Fragment C

Now in Fragment C,I go to Permission Setting and make access Camera to Deny,then I return an App.I realize that app restarted (transit to Fragment A). May you give me any reason and suggestion to solve it. Thanks in advance!

Unkenned answered 25/3, 2017 at 16:20 Comment(11)
post some code please\Dedra
Your process will be terminated if the user revokes one of your permissions in Settings. This is no different than if the user navigated away from your app (e.g., pressed HOME) and your process was terminated while it was in the background. When the user tries to return to your app, if it has been < ~30 minutes since the user left, Android will fork a fresh process for you and recreate your last activity. You can simulate this by running your app, pressing HOME, terminating your process from Android Studio, and then returning to your app via the overview (recent tasks) screen.Incommunicable
@Incommunicable is this perhaps related to the Activity's state?Dedra
@Incommunicable is there any solution to keep current fragment display after change permission?Unkenned
@do87: That should happen automatically. It suggests that you are not properly handling the case where your activity is being recreated. Do you handle configuration changes properly (e.g., rotate the screen)? If not, fix that, and it should fix this process-termination scenario.Incommunicable
Thanks @CommonsWare. Helpful information for me.Unkenned
@Incommunicable "Your process will be terminated if the user revokes one of your permissions in Settings." Is that mentioned specifically in Android Doc?Greed
@voidpointer: I do not recall it being mentioned there, but I have not looked for that information recently.Incommunicable
@Incommunicable I have a facing same issue is there any proper solution.Hialeah
@DarshanMistry: I do not know what you would consider a "proper solution" would be.Incommunicable
I also can't find any of this in the docs, which means this behavior can change at any timeEtching

© 2022 - 2024 — McMap. All rights reserved.