Request permission dialog pauses my activity

后端 未结 3 1007
隐瞒了意图╮
隐瞒了意图╮ 2021-01-22 15:47

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 disp

3条回答
  •  [愿得一人]
    2021-01-22 16:13

    what is happening is that my activity is being paused while request permission dialog is displayed. Why is that?

    requestPermissions docs says

    This method may start an activity allowing the user to choose which permissions to grant and which to reject. Hence, you should be prepared that your activity may be paused and resumed. Further, granting some permissions may require a restart of you application. In such a case, the system will recreate the activity stack before delivering the result to your onRequestPermissionsResult(int, String[], int[]).

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

提交回复
热议问题