请求权限对话框会暂停我的活动

请求权限对话框会暂停我的活动

本文介绍了请求权限对话框会暂停我的活动的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在我的活动的 onActivityResult 内请求许可,发生的事情是我的活动在显示请求许可权对话框时被暂停.为什么会这样,我可以以某种方式阻止它吗?

I am asking for permission inside onActivityResult of my activity and what is happening is that my activity is being paused while request permission dialog is displayed. Why is that and can I somehow prevent it?

我所做的只是以正常方式请求许可:

All I doing is asking for permission in a normal way:

if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M && (ActivityCompat.checkSelfPermission(this, Manifest.permission.ACCESS_FINE_LOCATION) != PackageManager.PERMISSION_GRANTED ||
                ActivityCompat.checkSelfPermission(this, Manifest.permission.ACCESS_COARSE_LOCATION) != PackageManager.PERMISSION_GRANTED)) {
                requestPermissions(new String[]{Manifest.permission.ACCESS_FINE_LOCATION, Manifest.permission.ACCESS_COARSE_LOCATION},
                        REQUEST_LOCATION_ACCESS_CODE);

推荐答案

requestPermissions文档说

尽管另一种解决方案是在可能的情况下将代码移动到 onStop

Although an another solution is move your code in onStop if possible and suitable

这篇关于请求权限对话框会暂停我的活动的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-23 01:28