What happens when a permission is disabled at runtime?












0














I couldn't find any information about what happens when the user disables an app's permission while the app is running.



Is the application re-initilized?



I saw that in some apps if a Dialog or BottomSheet is open while I disable the permission, the dialog is no longer displayed when I return to the app.



Can anyone explain what happens in-detail when a permission is denied at runtime? Or does anyone have some useful links for me?



I would be especially interested in which lifecycle events are called when returning to the app.










share|improve this question
























  • Check out this tutorial : medium.com/@muthuraj57/…, let me know if confused at anything !
    – Jeel Vankhede
    Nov 12 at 13:34










  • Thanks Jeel for the tip, but that tutorial does not really answer my question. I would be interested in the android lifecycle events when the app initially has the permissions it needs, and then, while the app is running, the user disables a (before granted) permission.
    – buellas
    Nov 12 at 13:48
















0














I couldn't find any information about what happens when the user disables an app's permission while the app is running.



Is the application re-initilized?



I saw that in some apps if a Dialog or BottomSheet is open while I disable the permission, the dialog is no longer displayed when I return to the app.



Can anyone explain what happens in-detail when a permission is denied at runtime? Or does anyone have some useful links for me?



I would be especially interested in which lifecycle events are called when returning to the app.










share|improve this question
























  • Check out this tutorial : medium.com/@muthuraj57/…, let me know if confused at anything !
    – Jeel Vankhede
    Nov 12 at 13:34










  • Thanks Jeel for the tip, but that tutorial does not really answer my question. I would be interested in the android lifecycle events when the app initially has the permissions it needs, and then, while the app is running, the user disables a (before granted) permission.
    – buellas
    Nov 12 at 13:48














0












0








0







I couldn't find any information about what happens when the user disables an app's permission while the app is running.



Is the application re-initilized?



I saw that in some apps if a Dialog or BottomSheet is open while I disable the permission, the dialog is no longer displayed when I return to the app.



Can anyone explain what happens in-detail when a permission is denied at runtime? Or does anyone have some useful links for me?



I would be especially interested in which lifecycle events are called when returning to the app.










share|improve this question















I couldn't find any information about what happens when the user disables an app's permission while the app is running.



Is the application re-initilized?



I saw that in some apps if a Dialog or BottomSheet is open while I disable the permission, the dialog is no longer displayed when I return to the app.



Can anyone explain what happens in-detail when a permission is denied at runtime? Or does anyone have some useful links for me?



I would be especially interested in which lifecycle events are called when returning to the app.







android permissions






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Nov 12 at 13:40

























asked Nov 12 at 13:24









buellas

8419




8419












  • Check out this tutorial : medium.com/@muthuraj57/…, let me know if confused at anything !
    – Jeel Vankhede
    Nov 12 at 13:34










  • Thanks Jeel for the tip, but that tutorial does not really answer my question. I would be interested in the android lifecycle events when the app initially has the permissions it needs, and then, while the app is running, the user disables a (before granted) permission.
    – buellas
    Nov 12 at 13:48


















  • Check out this tutorial : medium.com/@muthuraj57/…, let me know if confused at anything !
    – Jeel Vankhede
    Nov 12 at 13:34










  • Thanks Jeel for the tip, but that tutorial does not really answer my question. I would be interested in the android lifecycle events when the app initially has the permissions it needs, and then, while the app is running, the user disables a (before granted) permission.
    – buellas
    Nov 12 at 13:48
















Check out this tutorial : medium.com/@muthuraj57/…, let me know if confused at anything !
– Jeel Vankhede
Nov 12 at 13:34




Check out this tutorial : medium.com/@muthuraj57/…, let me know if confused at anything !
– Jeel Vankhede
Nov 12 at 13:34












Thanks Jeel for the tip, but that tutorial does not really answer my question. I would be interested in the android lifecycle events when the app initially has the permissions it needs, and then, while the app is running, the user disables a (before granted) permission.
– buellas
Nov 12 at 13:48




Thanks Jeel for the tip, but that tutorial does not really answer my question. I would be interested in the android lifecycle events when the app initially has the permissions it needs, and then, while the app is running, the user disables a (before granted) permission.
– buellas
Nov 12 at 13:48












3 Answers
3






active

oldest

votes


















1














When a previously granted permission is revoked through settings, the app is force stopped. You can see this by watching your app in the debugger. The app process is marked DEAD as soon as the permission is revoked.



Returning to the app will launch it from the main activity. I've never really looked into why this happens, but I assume it's because when a granted permission is revoked, the user could be deep into the app at a place where it is assumed the permission is granted. When the permission is revoked, there's no way to know if the screen they are currently in is even valid anymore.



Upon returning to the app, the app's state is restored and your current activity will be restarted, similar to a configuration change. If the activity you are in assumes a certain permission is granted, you should probably check that permission again in onCreate() to make sure you have it.






share|improve this answer























  • hmm, well now that I'm testing this in Pie, it seems the behavior has changed. The app is no longer being force closed when a permission is revoked. But I am being kicked back a couple screens to a point where I don't need the permission.
    – Greg Moens
    Nov 12 at 14:41










  • I guess I didn't understand this flow as well as I thought I did! Answer updated.
    – Greg Moens
    Nov 12 at 15:08



















0














Simply put, That depends on what the app is trying to do when it needs permission.



For example: If we live in a country that requires you to be an adult to watch any video on YouTube, nothing will work with Location permissions denied



Another example: If you want to take photos using your phone via an app, the Camera permission should be permitted.



Under some circumstances, just part functions of app can not be used, but at an Extreme case, app would throw Security Exception and crash.






share|improve this answer





























    0














    According to your point :




    I saw that in some apps if a Dialog or BottomSheet is open while I
    disable the permission, the dialog is no longer displayed when I
    return to the app.




    There is no lifecycle callback about what you do once permission is denied, but there's method on ActivityCompat which gives you flag if you want to show your own Dialog/BottomSheet



    So, you can call shouldShowRequestPermissionRationale() method from ActivityCompat & make your own logic work when it's true.




    shouldShowRequestPermissionRationale :




    Gets whether you should show UI with rationale for requesting a permission. You should do this only if you do not have the permission and the context in which the permission is requested does not clearly communicate to the user what would be the benefit from granting this permission.



    For example,



    if you write a camera app, requesting the camera permission would be expected by the user and no rationale for why it is requested is needed.



    If however, the app needs location for tagging photos then a non-tech savvy user may wonder how location is related to taking photos. In this case you may choose to show UI with rationale of requesting this permission.





    While disabling permission for first time will give you callback in onRequestPermissionResult() method.






    share|improve this answer





















      Your Answer






      StackExchange.ifUsing("editor", function () {
      StackExchange.using("externalEditor", function () {
      StackExchange.using("snippets", function () {
      StackExchange.snippets.init();
      });
      });
      }, "code-snippets");

      StackExchange.ready(function() {
      var channelOptions = {
      tags: "".split(" "),
      id: "1"
      };
      initTagRenderer("".split(" "), "".split(" "), channelOptions);

      StackExchange.using("externalEditor", function() {
      // Have to fire editor after snippets, if snippets enabled
      if (StackExchange.settings.snippets.snippetsEnabled) {
      StackExchange.using("snippets", function() {
      createEditor();
      });
      }
      else {
      createEditor();
      }
      });

      function createEditor() {
      StackExchange.prepareEditor({
      heartbeatType: 'answer',
      autoActivateHeartbeat: false,
      convertImagesToLinks: true,
      noModals: true,
      showLowRepImageUploadWarning: true,
      reputationToPostImages: 10,
      bindNavPrevention: true,
      postfix: "",
      imageUploader: {
      brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
      contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
      allowUrls: true
      },
      onDemand: true,
      discardSelector: ".discard-answer"
      ,immediatelyShowMarkdownHelp:true
      });


      }
      });














      draft saved

      draft discarded


















      StackExchange.ready(
      function () {
      StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53263149%2fwhat-happens-when-a-permission-is-disabled-at-runtime%23new-answer', 'question_page');
      }
      );

      Post as a guest















      Required, but never shown

























      3 Answers
      3






      active

      oldest

      votes








      3 Answers
      3






      active

      oldest

      votes









      active

      oldest

      votes






      active

      oldest

      votes









      1














      When a previously granted permission is revoked through settings, the app is force stopped. You can see this by watching your app in the debugger. The app process is marked DEAD as soon as the permission is revoked.



      Returning to the app will launch it from the main activity. I've never really looked into why this happens, but I assume it's because when a granted permission is revoked, the user could be deep into the app at a place where it is assumed the permission is granted. When the permission is revoked, there's no way to know if the screen they are currently in is even valid anymore.



      Upon returning to the app, the app's state is restored and your current activity will be restarted, similar to a configuration change. If the activity you are in assumes a certain permission is granted, you should probably check that permission again in onCreate() to make sure you have it.






      share|improve this answer























      • hmm, well now that I'm testing this in Pie, it seems the behavior has changed. The app is no longer being force closed when a permission is revoked. But I am being kicked back a couple screens to a point where I don't need the permission.
        – Greg Moens
        Nov 12 at 14:41










      • I guess I didn't understand this flow as well as I thought I did! Answer updated.
        – Greg Moens
        Nov 12 at 15:08
















      1














      When a previously granted permission is revoked through settings, the app is force stopped. You can see this by watching your app in the debugger. The app process is marked DEAD as soon as the permission is revoked.



      Returning to the app will launch it from the main activity. I've never really looked into why this happens, but I assume it's because when a granted permission is revoked, the user could be deep into the app at a place where it is assumed the permission is granted. When the permission is revoked, there's no way to know if the screen they are currently in is even valid anymore.



      Upon returning to the app, the app's state is restored and your current activity will be restarted, similar to a configuration change. If the activity you are in assumes a certain permission is granted, you should probably check that permission again in onCreate() to make sure you have it.






      share|improve this answer























      • hmm, well now that I'm testing this in Pie, it seems the behavior has changed. The app is no longer being force closed when a permission is revoked. But I am being kicked back a couple screens to a point where I don't need the permission.
        – Greg Moens
        Nov 12 at 14:41










      • I guess I didn't understand this flow as well as I thought I did! Answer updated.
        – Greg Moens
        Nov 12 at 15:08














      1












      1








      1






      When a previously granted permission is revoked through settings, the app is force stopped. You can see this by watching your app in the debugger. The app process is marked DEAD as soon as the permission is revoked.



      Returning to the app will launch it from the main activity. I've never really looked into why this happens, but I assume it's because when a granted permission is revoked, the user could be deep into the app at a place where it is assumed the permission is granted. When the permission is revoked, there's no way to know if the screen they are currently in is even valid anymore.



      Upon returning to the app, the app's state is restored and your current activity will be restarted, similar to a configuration change. If the activity you are in assumes a certain permission is granted, you should probably check that permission again in onCreate() to make sure you have it.






      share|improve this answer














      When a previously granted permission is revoked through settings, the app is force stopped. You can see this by watching your app in the debugger. The app process is marked DEAD as soon as the permission is revoked.



      Returning to the app will launch it from the main activity. I've never really looked into why this happens, but I assume it's because when a granted permission is revoked, the user could be deep into the app at a place where it is assumed the permission is granted. When the permission is revoked, there's no way to know if the screen they are currently in is even valid anymore.



      Upon returning to the app, the app's state is restored and your current activity will be restarted, similar to a configuration change. If the activity you are in assumes a certain permission is granted, you should probably check that permission again in onCreate() to make sure you have it.







      share|improve this answer














      share|improve this answer



      share|improve this answer








      edited Nov 12 at 15:06

























      answered Nov 12 at 14:33









      Greg Moens

      3168




      3168












      • hmm, well now that I'm testing this in Pie, it seems the behavior has changed. The app is no longer being force closed when a permission is revoked. But I am being kicked back a couple screens to a point where I don't need the permission.
        – Greg Moens
        Nov 12 at 14:41










      • I guess I didn't understand this flow as well as I thought I did! Answer updated.
        – Greg Moens
        Nov 12 at 15:08


















      • hmm, well now that I'm testing this in Pie, it seems the behavior has changed. The app is no longer being force closed when a permission is revoked. But I am being kicked back a couple screens to a point where I don't need the permission.
        – Greg Moens
        Nov 12 at 14:41










      • I guess I didn't understand this flow as well as I thought I did! Answer updated.
        – Greg Moens
        Nov 12 at 15:08
















      hmm, well now that I'm testing this in Pie, it seems the behavior has changed. The app is no longer being force closed when a permission is revoked. But I am being kicked back a couple screens to a point where I don't need the permission.
      – Greg Moens
      Nov 12 at 14:41




      hmm, well now that I'm testing this in Pie, it seems the behavior has changed. The app is no longer being force closed when a permission is revoked. But I am being kicked back a couple screens to a point where I don't need the permission.
      – Greg Moens
      Nov 12 at 14:41












      I guess I didn't understand this flow as well as I thought I did! Answer updated.
      – Greg Moens
      Nov 12 at 15:08




      I guess I didn't understand this flow as well as I thought I did! Answer updated.
      – Greg Moens
      Nov 12 at 15:08













      0














      Simply put, That depends on what the app is trying to do when it needs permission.



      For example: If we live in a country that requires you to be an adult to watch any video on YouTube, nothing will work with Location permissions denied



      Another example: If you want to take photos using your phone via an app, the Camera permission should be permitted.



      Under some circumstances, just part functions of app can not be used, but at an Extreme case, app would throw Security Exception and crash.






      share|improve this answer


























        0














        Simply put, That depends on what the app is trying to do when it needs permission.



        For example: If we live in a country that requires you to be an adult to watch any video on YouTube, nothing will work with Location permissions denied



        Another example: If you want to take photos using your phone via an app, the Camera permission should be permitted.



        Under some circumstances, just part functions of app can not be used, but at an Extreme case, app would throw Security Exception and crash.






        share|improve this answer
























          0












          0








          0






          Simply put, That depends on what the app is trying to do when it needs permission.



          For example: If we live in a country that requires you to be an adult to watch any video on YouTube, nothing will work with Location permissions denied



          Another example: If you want to take photos using your phone via an app, the Camera permission should be permitted.



          Under some circumstances, just part functions of app can not be used, but at an Extreme case, app would throw Security Exception and crash.






          share|improve this answer












          Simply put, That depends on what the app is trying to do when it needs permission.



          For example: If we live in a country that requires you to be an adult to watch any video on YouTube, nothing will work with Location permissions denied



          Another example: If you want to take photos using your phone via an app, the Camera permission should be permitted.



          Under some circumstances, just part functions of app can not be used, but at an Extreme case, app would throw Security Exception and crash.







          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered Nov 12 at 13:50









          navylover

          3,32021118




          3,32021118























              0














              According to your point :




              I saw that in some apps if a Dialog or BottomSheet is open while I
              disable the permission, the dialog is no longer displayed when I
              return to the app.




              There is no lifecycle callback about what you do once permission is denied, but there's method on ActivityCompat which gives you flag if you want to show your own Dialog/BottomSheet



              So, you can call shouldShowRequestPermissionRationale() method from ActivityCompat & make your own logic work when it's true.




              shouldShowRequestPermissionRationale :




              Gets whether you should show UI with rationale for requesting a permission. You should do this only if you do not have the permission and the context in which the permission is requested does not clearly communicate to the user what would be the benefit from granting this permission.



              For example,



              if you write a camera app, requesting the camera permission would be expected by the user and no rationale for why it is requested is needed.



              If however, the app needs location for tagging photos then a non-tech savvy user may wonder how location is related to taking photos. In this case you may choose to show UI with rationale of requesting this permission.





              While disabling permission for first time will give you callback in onRequestPermissionResult() method.






              share|improve this answer


























                0














                According to your point :




                I saw that in some apps if a Dialog or BottomSheet is open while I
                disable the permission, the dialog is no longer displayed when I
                return to the app.




                There is no lifecycle callback about what you do once permission is denied, but there's method on ActivityCompat which gives you flag if you want to show your own Dialog/BottomSheet



                So, you can call shouldShowRequestPermissionRationale() method from ActivityCompat & make your own logic work when it's true.




                shouldShowRequestPermissionRationale :




                Gets whether you should show UI with rationale for requesting a permission. You should do this only if you do not have the permission and the context in which the permission is requested does not clearly communicate to the user what would be the benefit from granting this permission.



                For example,



                if you write a camera app, requesting the camera permission would be expected by the user and no rationale for why it is requested is needed.



                If however, the app needs location for tagging photos then a non-tech savvy user may wonder how location is related to taking photos. In this case you may choose to show UI with rationale of requesting this permission.





                While disabling permission for first time will give you callback in onRequestPermissionResult() method.






                share|improve this answer
























                  0












                  0








                  0






                  According to your point :




                  I saw that in some apps if a Dialog or BottomSheet is open while I
                  disable the permission, the dialog is no longer displayed when I
                  return to the app.




                  There is no lifecycle callback about what you do once permission is denied, but there's method on ActivityCompat which gives you flag if you want to show your own Dialog/BottomSheet



                  So, you can call shouldShowRequestPermissionRationale() method from ActivityCompat & make your own logic work when it's true.




                  shouldShowRequestPermissionRationale :




                  Gets whether you should show UI with rationale for requesting a permission. You should do this only if you do not have the permission and the context in which the permission is requested does not clearly communicate to the user what would be the benefit from granting this permission.



                  For example,



                  if you write a camera app, requesting the camera permission would be expected by the user and no rationale for why it is requested is needed.



                  If however, the app needs location for tagging photos then a non-tech savvy user may wonder how location is related to taking photos. In this case you may choose to show UI with rationale of requesting this permission.





                  While disabling permission for first time will give you callback in onRequestPermissionResult() method.






                  share|improve this answer












                  According to your point :




                  I saw that in some apps if a Dialog or BottomSheet is open while I
                  disable the permission, the dialog is no longer displayed when I
                  return to the app.




                  There is no lifecycle callback about what you do once permission is denied, but there's method on ActivityCompat which gives you flag if you want to show your own Dialog/BottomSheet



                  So, you can call shouldShowRequestPermissionRationale() method from ActivityCompat & make your own logic work when it's true.




                  shouldShowRequestPermissionRationale :




                  Gets whether you should show UI with rationale for requesting a permission. You should do this only if you do not have the permission and the context in which the permission is requested does not clearly communicate to the user what would be the benefit from granting this permission.



                  For example,



                  if you write a camera app, requesting the camera permission would be expected by the user and no rationale for why it is requested is needed.



                  If however, the app needs location for tagging photos then a non-tech savvy user may wonder how location is related to taking photos. In this case you may choose to show UI with rationale of requesting this permission.





                  While disabling permission for first time will give you callback in onRequestPermissionResult() method.







                  share|improve this answer












                  share|improve this answer



                  share|improve this answer










                  answered Nov 12 at 14:03









                  Jeel Vankhede

                  2,0512216




                  2,0512216






























                      draft saved

                      draft discarded




















































                      Thanks for contributing an answer to Stack Overflow!


                      • Please be sure to answer the question. Provide details and share your research!

                      But avoid



                      • Asking for help, clarification, or responding to other answers.

                      • Making statements based on opinion; back them up with references or personal experience.


                      To learn more, see our tips on writing great answers.





                      Some of your past answers have not been well-received, and you're in danger of being blocked from answering.


                      Please pay close attention to the following guidance:


                      • Please be sure to answer the question. Provide details and share your research!

                      But avoid



                      • Asking for help, clarification, or responding to other answers.

                      • Making statements based on opinion; back them up with references or personal experience.


                      To learn more, see our tips on writing great answers.




                      draft saved


                      draft discarded














                      StackExchange.ready(
                      function () {
                      StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53263149%2fwhat-happens-when-a-permission-is-disabled-at-runtime%23new-answer', 'question_page');
                      }
                      );

                      Post as a guest















                      Required, but never shown





















































                      Required, but never shown














                      Required, but never shown












                      Required, but never shown







                      Required, but never shown

































                      Required, but never shown














                      Required, but never shown












                      Required, but never shown







                      Required, but never shown







                      Popular posts from this blog

                      Bressuire

                      Vorschmack

                      Quarantine