Force application to restart from first Activity (when a permission is denied)

后端 未结 5 1816
庸人自扰
庸人自扰 2021-02-02 09:46

It is known that when we deny permissions at runtime in Android 6.0 and resume the app from the recent menu, the app process

5条回答
  •  北荒
    北荒 (楼主)
    2021-02-02 10:17

    You should be handling Activity (re)creation using the Bundle provided by onCreate, saved by onSaveInstanceState, more information here.

    Pass in the Bundle all you need in order to recover from a previous state and restore your UI seamlessly. Your Activity can be recreated by many reasons, cancellation of permissions is just one of them, screen rotation is another, so as long as you can survive one, you can survive all of them.

提交回复
热议问题