search

Home  >  Q&A  >  body text

Android 6.0 运行中用户手动去设置界面取消该app的某个权限,app该怎么处理这块的逻辑?

Android 6.0 运行中用户手动去设置界面取消该app的某个权限,或者在权限设置界面取消然后再重新手动给与该权限,再次进入该app,其实里面的数据和对象已经被回收了但是有没有崩溃,界面还在。没有走onDestroy,onPause等函数,如果是 Fragment 会直接被回收,但是又没有走 onDestroyView , onDestroy ,onDetach 这些周期函数,宿主的周期函数也没有被执行,这个问题该怎么解决?有人可能会说在主活动onResume监听权限改变,但是只要上面第一句执行了,后面的都没用,曾经考虑过动态监听权限改变,然后得到结果后重启应用,这个目前是作为备用方案,希望可以在这里看看大家有没有更简单粗暴的好办法

怪我咯怪我咯2772 days ago670

reply all(5)I'll reply

  • 怪我咯

    怪我咯2017-04-17 18:02:53

    Thank you for your answers. My questions are not within the scope of your answers. I have restructured the project and completely solved this problem!

    reply
    0
  • 阿神

    阿神2017-04-17 18:02:53

    When you go to modify permissions, your activity will definitely switch out. OnStop will usually be called, at least onPause should also go. When you return to your interface, onResume will be called, so just check it in onResume. . If you are not sure, you can check again every time you obtain data (that is, where permissions are actually used).

    reply
    0
  • 伊谢尔伦

    伊谢尔伦2017-04-17 18:02:53

    The current thinking of methods:
    1. Write an annotation, add annotations to some methods that require permissions, and automatically detect permissions
    2. That is to detect where permissions are used and detect them every time

    reply
    0
  • PHP中文网

    PHP中文网2017-04-17 18:02:53

    If you always need these permissions, check them in onResume of baseActivity

    reply
    0
  • ringa_lee

    ringa_lee2017-04-17 18:02:53

    Hello, how did you solve this problem? I am also troubled by this problem recently

    reply
    0
  • Cancelreply