Android Marshmallow:更改运行应用程序的权限 [英] Android Marshmallow: permissions change for running app
问题描述
我知道,使用Android Marshmallow,每次我们需要需要权限的功能时,我们都必须询问权限.
I know, with Android Marshmallow, we have to ask permissions every time we need a functionality that require a permission.
我为新的应用程序执行此操作,但对于旧的BIG应用程序则更为复杂.
I do this for new App, but for old BIG App is more complicated.
对于旧的BIG App,我要求"MainActivity"中的所有权限.
For old BIG App, I ask all permissions in "MainActivity".
因此,我的应用程序启动并显示地图片段. 我毫无问题地要求获得位置许可.用户同意.
So, my app is started and shows a Map Fragment. I ask for Location Permission with no problem. The user agrees.
用户将其放在后台,进入应用程序设置"并拒绝权限. 然后他将应用程序置于前台:应用程序崩溃!
The user puts it in background, goes in the App Settings and denies permission. Then he puts the App in foreground: App crashes!!
我知道,使用地图片段有问题.
I know, there is a problem using Map Fragment.
但是该应用太大,无法分析每个权限.
But the App is too BIG to analyze every single permission.
我需要快速解决方案:权限更改--->重新启动应用程序!!!
I need the FAST solution: PERMISSION CHANGE ---> RESTART APP!!!
这就是GoogleMaps所做的!
And this is what GoogleMaps does!
我启动了GoogleMaps,并将其置于后台.
I started GoogleMaps, and put it in background.
GoogleMaps App权限,第一个区别:
GoogleMaps App permissions, the first difference:
在我的应用程序中,如果我拒绝了许可,则不会显示有关Google Maps的消息:
in my App, if I denied a permission, I haven't this message showing for Google Maps:
在那之后,如果我将GoogleMaps放在前台,则该应用程序可以毫无问题地重新启动:
After that, if I put GoogleMaps in foreground, the App restart with no problem:
我的应用需要这个.有人可以帮我吗?!?!?!?
I need this for my app. Can someone help me?!?!?!?
非常感谢!
推荐答案
撤消权限后,您的应用将被终止并重新启动.当您在后台撤消应用程序的权限时,请查看logcat.你会看见 : I/ActivityManager(572):杀死13896:com.your.app/uxxxx():权限被撤销 因此,您只需要在onCreate()函数的类"myApplication extended Application"中检查权限.
When permissions are revoked, your app is killed and restarted. Look on the logcat when you revoke permission with your application in background. You will see : I/ActivityManager(572): Killing 13896:com.your.app/uxxxx (): permissions revoked So you need to only check permissions in your class "myApplication extends Application" in the onCreate() function.
这篇关于Android Marshmallow:更改运行应用程序的权限的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!