RequestPermission () does not completely recreate the action stack

I have activity A, which starts activity B. Then this activity requests READ_EXTERNAL_STORAGEand WRITE_EXTERNAL_STORAGE. On Android 6.0, a permission dialog appears (which immediately destroys activity B as soon as the popup opens). However, no matter which user chooses, the system will return to activity A.

Requesting other permissions works fine elsewhere, but I believe that permissions to external storage are some of those that, as the docs warn, require the application to restart and the system recreates the activity stack.

My problem is that activity B is never recreated, not to mention onRequestPermissionsResult. I would think that "recreating the activity stack" includes starting activity B again, and ideally onRequestPermissionResultcalled on it. How should I handle this?

+4
source share
1 answer

which immediately destroys activity B as soon as the dialog box appears

That sounds weird to me. Action B should be suspended (and possibly stopped) at this point, but not destroyed. Are you sure you are not calling finish()or using any property, for example noHistory?

, am_finish_activity / am_destroy_activity . , Gmail BACK ( app-request finish-imm):

$ adb logcat -bevents
I/am_finish_activity( 1155): [0,947820256,3228,com.google.android.gm/.ConversationListActivityGmail,app-request]
I/am_pause_activity( 1155): [0,947820256,com.google.android.gm/.ConversationListActivityGmail]
I/am_on_paused_called(17619): [0,com.google.android.gm.ConversationListActivityGmail]
I/am_home_stack_moved( 1155): [0,1,0,0,prevFinished]
I/wm_task_moved( 1155): [3162,1,1]
I/am_focused_activity( 1155): [0,com.android.launcher/com.android.launcher2.Launcher]
I/am_resume_activity( 1155): [0,285205047,3162,com.android.launcher/com.android.launcher2.Launcher]
I/am_on_resume_called(24956): [0,com.android.launcher2.Launcher]
I/am_destroy_activity( 1155): [0,947820256,3228,com.google.android.gm/.ConversationListActivityGmail,finish-imm]

, , , .

+8

Source: https://habr.com/ru/post/1613152/


All Articles