User Revoke Permission











up vote
0
down vote

favorite












When a user revokes permissions in settings of the phone for the android app, the process will be terminated/killed and when the user opens the app again, it will crash. Is there a possibility that the app will not crash in order for the user to remain in the activity he or she just left ? If there is, how? I am still new to android development.










share|improve this question









New contributor




Neil Marjun Martinez is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
















  • 4




    "and when user opens the app again, it will crash" Why would it crash? Are you not checking for permission before every operation that requires a permission?
    – Michael
    Nov 8 at 9:25










  • @Michael, I was checking. I read also here that when user granted the permission and by some time he or she revokes it on the phone settings, the app is running on the background and it will terminate or kill the process after the permissions are revoked.
    – Neil Marjun Martinez
    Nov 8 at 9:33












  • Yeah I'm with you so far. What I don't understand is why the app would crash when you try to start it again. It sounds to me like your app is trying to do something that requires a permission without checking whether it has that permission. You need to check for permission every time, not just once.
    – Michael
    Nov 8 at 9:36










  • @Michael I see. I got you. Thank you so much. Appreciate it! :)
    – Neil Marjun Martinez
    Nov 8 at 9:41










  • @Michael, even if I added codes in my onResume, all the data will be null causes the app to crash.
    – Neil Marjun Martinez
    Nov 8 at 9:55















up vote
0
down vote

favorite












When a user revokes permissions in settings of the phone for the android app, the process will be terminated/killed and when the user opens the app again, it will crash. Is there a possibility that the app will not crash in order for the user to remain in the activity he or she just left ? If there is, how? I am still new to android development.










share|improve this question









New contributor




Neil Marjun Martinez is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
















  • 4




    "and when user opens the app again, it will crash" Why would it crash? Are you not checking for permission before every operation that requires a permission?
    – Michael
    Nov 8 at 9:25










  • @Michael, I was checking. I read also here that when user granted the permission and by some time he or she revokes it on the phone settings, the app is running on the background and it will terminate or kill the process after the permissions are revoked.
    – Neil Marjun Martinez
    Nov 8 at 9:33












  • Yeah I'm with you so far. What I don't understand is why the app would crash when you try to start it again. It sounds to me like your app is trying to do something that requires a permission without checking whether it has that permission. You need to check for permission every time, not just once.
    – Michael
    Nov 8 at 9:36










  • @Michael I see. I got you. Thank you so much. Appreciate it! :)
    – Neil Marjun Martinez
    Nov 8 at 9:41










  • @Michael, even if I added codes in my onResume, all the data will be null causes the app to crash.
    – Neil Marjun Martinez
    Nov 8 at 9:55













up vote
0
down vote

favorite









up vote
0
down vote

favorite











When a user revokes permissions in settings of the phone for the android app, the process will be terminated/killed and when the user opens the app again, it will crash. Is there a possibility that the app will not crash in order for the user to remain in the activity he or she just left ? If there is, how? I am still new to android development.










share|improve this question









New contributor




Neil Marjun Martinez is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.











When a user revokes permissions in settings of the phone for the android app, the process will be terminated/killed and when the user opens the app again, it will crash. Is there a possibility that the app will not crash in order for the user to remain in the activity he or she just left ? If there is, how? I am still new to android development.







android permissions






share|improve this question









New contributor




Neil Marjun Martinez is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.











share|improve this question









New contributor




Neil Marjun Martinez is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.









share|improve this question




share|improve this question








edited Nov 8 at 9:55





















New contributor




Neil Marjun Martinez is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.









asked Nov 8 at 9:21









Neil Marjun Martinez

11




11




New contributor




Neil Marjun Martinez is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.





New contributor





Neil Marjun Martinez is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.






Neil Marjun Martinez is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.








  • 4




    "and when user opens the app again, it will crash" Why would it crash? Are you not checking for permission before every operation that requires a permission?
    – Michael
    Nov 8 at 9:25










  • @Michael, I was checking. I read also here that when user granted the permission and by some time he or she revokes it on the phone settings, the app is running on the background and it will terminate or kill the process after the permissions are revoked.
    – Neil Marjun Martinez
    Nov 8 at 9:33












  • Yeah I'm with you so far. What I don't understand is why the app would crash when you try to start it again. It sounds to me like your app is trying to do something that requires a permission without checking whether it has that permission. You need to check for permission every time, not just once.
    – Michael
    Nov 8 at 9:36










  • @Michael I see. I got you. Thank you so much. Appreciate it! :)
    – Neil Marjun Martinez
    Nov 8 at 9:41










  • @Michael, even if I added codes in my onResume, all the data will be null causes the app to crash.
    – Neil Marjun Martinez
    Nov 8 at 9:55














  • 4




    "and when user opens the app again, it will crash" Why would it crash? Are you not checking for permission before every operation that requires a permission?
    – Michael
    Nov 8 at 9:25










  • @Michael, I was checking. I read also here that when user granted the permission and by some time he or she revokes it on the phone settings, the app is running on the background and it will terminate or kill the process after the permissions are revoked.
    – Neil Marjun Martinez
    Nov 8 at 9:33












  • Yeah I'm with you so far. What I don't understand is why the app would crash when you try to start it again. It sounds to me like your app is trying to do something that requires a permission without checking whether it has that permission. You need to check for permission every time, not just once.
    – Michael
    Nov 8 at 9:36










  • @Michael I see. I got you. Thank you so much. Appreciate it! :)
    – Neil Marjun Martinez
    Nov 8 at 9:41










  • @Michael, even if I added codes in my onResume, all the data will be null causes the app to crash.
    – Neil Marjun Martinez
    Nov 8 at 9:55








4




4




"and when user opens the app again, it will crash" Why would it crash? Are you not checking for permission before every operation that requires a permission?
– Michael
Nov 8 at 9:25




"and when user opens the app again, it will crash" Why would it crash? Are you not checking for permission before every operation that requires a permission?
– Michael
Nov 8 at 9:25












@Michael, I was checking. I read also here that when user granted the permission and by some time he or she revokes it on the phone settings, the app is running on the background and it will terminate or kill the process after the permissions are revoked.
– Neil Marjun Martinez
Nov 8 at 9:33






@Michael, I was checking. I read also here that when user granted the permission and by some time he or she revokes it on the phone settings, the app is running on the background and it will terminate or kill the process after the permissions are revoked.
– Neil Marjun Martinez
Nov 8 at 9:33














Yeah I'm with you so far. What I don't understand is why the app would crash when you try to start it again. It sounds to me like your app is trying to do something that requires a permission without checking whether it has that permission. You need to check for permission every time, not just once.
– Michael
Nov 8 at 9:36




Yeah I'm with you so far. What I don't understand is why the app would crash when you try to start it again. It sounds to me like your app is trying to do something that requires a permission without checking whether it has that permission. You need to check for permission every time, not just once.
– Michael
Nov 8 at 9:36












@Michael I see. I got you. Thank you so much. Appreciate it! :)
– Neil Marjun Martinez
Nov 8 at 9:41




@Michael I see. I got you. Thank you so much. Appreciate it! :)
– Neil Marjun Martinez
Nov 8 at 9:41












@Michael, even if I added codes in my onResume, all the data will be null causes the app to crash.
– Neil Marjun Martinez
Nov 8 at 9:55




@Michael, even if I added codes in my onResume, all the data will be null causes the app to crash.
– Neil Marjun Martinez
Nov 8 at 9:55












2 Answers
2






active

oldest

votes

















up vote
0
down vote













When app is re-opened you can catch onResume and check if you still have the permission to continue whatever they were doing before turning the permission off.



@Override
protected void onResume()
{
super.onResume();
if (ContextCompat.checkSelfPermission(this, Manifest.permission.ACCESS_FINE_LOCATION) == PackageManager.PERMISSION_GRANTED)
{
//We have the location permission!
//We can continue :)
}
else
{
//We don't have the permission anymore :(
finish();
//Or we can request it again, maybe show a dialog saying that it's needed in order to continue?
}
}





share|improve this answer





















  • still it gets error, the data during broadcast/live video will be null.
    – Neil Marjun Martinez
    Nov 8 at 9:52










  • If you don't have the permission anymore, you should pause whatever is broadcasting/getting the data until either 1) user gives you the permission again 2) user wants to stop whatever is happening
    – Ezzy
    Nov 8 at 9:54










  • Not pause the permission. But if you no longer have the permission you need then you should stop whatever code is being executed that is dependant on the permission.
    – Ezzy
    Nov 8 at 10:02










  • Okay sir! Thank you. I understand it now! :)
    – Neil Marjun Martinez
    Nov 8 at 10:03


















up vote
0
down vote













Please note that requesting permissions in the onResume() method is not a good idea, due to the fact that if for instance the user didn't grant the permission a dialog will appear asking the user to grant the permission and the activity will go in to the onPause() state. Then if the user will deny the permission, the activity will go back to the onResume() state and ask for the permission again, which will cause an infinite loop if the user won't approve or check the "Don't ask me again" checkBox. I suggested you implement the logic in the onStart() 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',
    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
    });


    }
    });






    Neil Marjun Martinez is a new contributor. Be nice, and check out our Code of Conduct.










     

    draft saved


    draft discarded


















    StackExchange.ready(
    function () {
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53204711%2fuser-revoke-permission%23new-answer', 'question_page');
    }
    );

    Post as a guest
































    2 Answers
    2






    active

    oldest

    votes








    2 Answers
    2






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes








    up vote
    0
    down vote













    When app is re-opened you can catch onResume and check if you still have the permission to continue whatever they were doing before turning the permission off.



    @Override
    protected void onResume()
    {
    super.onResume();
    if (ContextCompat.checkSelfPermission(this, Manifest.permission.ACCESS_FINE_LOCATION) == PackageManager.PERMISSION_GRANTED)
    {
    //We have the location permission!
    //We can continue :)
    }
    else
    {
    //We don't have the permission anymore :(
    finish();
    //Or we can request it again, maybe show a dialog saying that it's needed in order to continue?
    }
    }





    share|improve this answer





















    • still it gets error, the data during broadcast/live video will be null.
      – Neil Marjun Martinez
      Nov 8 at 9:52










    • If you don't have the permission anymore, you should pause whatever is broadcasting/getting the data until either 1) user gives you the permission again 2) user wants to stop whatever is happening
      – Ezzy
      Nov 8 at 9:54










    • Not pause the permission. But if you no longer have the permission you need then you should stop whatever code is being executed that is dependant on the permission.
      – Ezzy
      Nov 8 at 10:02










    • Okay sir! Thank you. I understand it now! :)
      – Neil Marjun Martinez
      Nov 8 at 10:03















    up vote
    0
    down vote













    When app is re-opened you can catch onResume and check if you still have the permission to continue whatever they were doing before turning the permission off.



    @Override
    protected void onResume()
    {
    super.onResume();
    if (ContextCompat.checkSelfPermission(this, Manifest.permission.ACCESS_FINE_LOCATION) == PackageManager.PERMISSION_GRANTED)
    {
    //We have the location permission!
    //We can continue :)
    }
    else
    {
    //We don't have the permission anymore :(
    finish();
    //Or we can request it again, maybe show a dialog saying that it's needed in order to continue?
    }
    }





    share|improve this answer





















    • still it gets error, the data during broadcast/live video will be null.
      – Neil Marjun Martinez
      Nov 8 at 9:52










    • If you don't have the permission anymore, you should pause whatever is broadcasting/getting the data until either 1) user gives you the permission again 2) user wants to stop whatever is happening
      – Ezzy
      Nov 8 at 9:54










    • Not pause the permission. But if you no longer have the permission you need then you should stop whatever code is being executed that is dependant on the permission.
      – Ezzy
      Nov 8 at 10:02










    • Okay sir! Thank you. I understand it now! :)
      – Neil Marjun Martinez
      Nov 8 at 10:03













    up vote
    0
    down vote










    up vote
    0
    down vote









    When app is re-opened you can catch onResume and check if you still have the permission to continue whatever they were doing before turning the permission off.



    @Override
    protected void onResume()
    {
    super.onResume();
    if (ContextCompat.checkSelfPermission(this, Manifest.permission.ACCESS_FINE_LOCATION) == PackageManager.PERMISSION_GRANTED)
    {
    //We have the location permission!
    //We can continue :)
    }
    else
    {
    //We don't have the permission anymore :(
    finish();
    //Or we can request it again, maybe show a dialog saying that it's needed in order to continue?
    }
    }





    share|improve this answer












    When app is re-opened you can catch onResume and check if you still have the permission to continue whatever they were doing before turning the permission off.



    @Override
    protected void onResume()
    {
    super.onResume();
    if (ContextCompat.checkSelfPermission(this, Manifest.permission.ACCESS_FINE_LOCATION) == PackageManager.PERMISSION_GRANTED)
    {
    //We have the location permission!
    //We can continue :)
    }
    else
    {
    //We don't have the permission anymore :(
    finish();
    //Or we can request it again, maybe show a dialog saying that it's needed in order to continue?
    }
    }






    share|improve this answer












    share|improve this answer



    share|improve this answer










    answered Nov 8 at 9:36









    Ezzy

    6122621




    6122621












    • still it gets error, the data during broadcast/live video will be null.
      – Neil Marjun Martinez
      Nov 8 at 9:52










    • If you don't have the permission anymore, you should pause whatever is broadcasting/getting the data until either 1) user gives you the permission again 2) user wants to stop whatever is happening
      – Ezzy
      Nov 8 at 9:54










    • Not pause the permission. But if you no longer have the permission you need then you should stop whatever code is being executed that is dependant on the permission.
      – Ezzy
      Nov 8 at 10:02










    • Okay sir! Thank you. I understand it now! :)
      – Neil Marjun Martinez
      Nov 8 at 10:03


















    • still it gets error, the data during broadcast/live video will be null.
      – Neil Marjun Martinez
      Nov 8 at 9:52










    • If you don't have the permission anymore, you should pause whatever is broadcasting/getting the data until either 1) user gives you the permission again 2) user wants to stop whatever is happening
      – Ezzy
      Nov 8 at 9:54










    • Not pause the permission. But if you no longer have the permission you need then you should stop whatever code is being executed that is dependant on the permission.
      – Ezzy
      Nov 8 at 10:02










    • Okay sir! Thank you. I understand it now! :)
      – Neil Marjun Martinez
      Nov 8 at 10:03
















    still it gets error, the data during broadcast/live video will be null.
    – Neil Marjun Martinez
    Nov 8 at 9:52




    still it gets error, the data during broadcast/live video will be null.
    – Neil Marjun Martinez
    Nov 8 at 9:52












    If you don't have the permission anymore, you should pause whatever is broadcasting/getting the data until either 1) user gives you the permission again 2) user wants to stop whatever is happening
    – Ezzy
    Nov 8 at 9:54




    If you don't have the permission anymore, you should pause whatever is broadcasting/getting the data until either 1) user gives you the permission again 2) user wants to stop whatever is happening
    – Ezzy
    Nov 8 at 9:54












    Not pause the permission. But if you no longer have the permission you need then you should stop whatever code is being executed that is dependant on the permission.
    – Ezzy
    Nov 8 at 10:02




    Not pause the permission. But if you no longer have the permission you need then you should stop whatever code is being executed that is dependant on the permission.
    – Ezzy
    Nov 8 at 10:02












    Okay sir! Thank you. I understand it now! :)
    – Neil Marjun Martinez
    Nov 8 at 10:03




    Okay sir! Thank you. I understand it now! :)
    – Neil Marjun Martinez
    Nov 8 at 10:03












    up vote
    0
    down vote













    Please note that requesting permissions in the onResume() method is not a good idea, due to the fact that if for instance the user didn't grant the permission a dialog will appear asking the user to grant the permission and the activity will go in to the onPause() state. Then if the user will deny the permission, the activity will go back to the onResume() state and ask for the permission again, which will cause an infinite loop if the user won't approve or check the "Don't ask me again" checkBox. I suggested you implement the logic in the onStart() method.






    share|improve this answer



























      up vote
      0
      down vote













      Please note that requesting permissions in the onResume() method is not a good idea, due to the fact that if for instance the user didn't grant the permission a dialog will appear asking the user to grant the permission and the activity will go in to the onPause() state. Then if the user will deny the permission, the activity will go back to the onResume() state and ask for the permission again, which will cause an infinite loop if the user won't approve or check the "Don't ask me again" checkBox. I suggested you implement the logic in the onStart() method.






      share|improve this answer

























        up vote
        0
        down vote










        up vote
        0
        down vote









        Please note that requesting permissions in the onResume() method is not a good idea, due to the fact that if for instance the user didn't grant the permission a dialog will appear asking the user to grant the permission and the activity will go in to the onPause() state. Then if the user will deny the permission, the activity will go back to the onResume() state and ask for the permission again, which will cause an infinite loop if the user won't approve or check the "Don't ask me again" checkBox. I suggested you implement the logic in the onStart() method.






        share|improve this answer














        Please note that requesting permissions in the onResume() method is not a good idea, due to the fact that if for instance the user didn't grant the permission a dialog will appear asking the user to grant the permission and the activity will go in to the onPause() state. Then if the user will deny the permission, the activity will go back to the onResume() state and ask for the permission again, which will cause an infinite loop if the user won't approve or check the "Don't ask me again" checkBox. I suggested you implement the logic in the onStart() method.







        share|improve this answer














        share|improve this answer



        share|improve this answer








        edited Nov 8 at 15:24

























        answered Nov 8 at 13:58









        Dor Solomon

        216




        216






















            Neil Marjun Martinez is a new contributor. Be nice, and check out our Code of Conduct.










             

            draft saved


            draft discarded


















            Neil Marjun Martinez is a new contributor. Be nice, and check out our Code of Conduct.













            Neil Marjun Martinez is a new contributor. Be nice, and check out our Code of Conduct.












            Neil Marjun Martinez is a new contributor. Be nice, and check out our Code of Conduct.















             


            draft saved


            draft discarded














            StackExchange.ready(
            function () {
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53204711%2fuser-revoke-permission%23new-answer', 'question_page');
            }
            );

            Post as a guest




















































































            Popular posts from this blog

            Guess what letter conforming each word

            Port of Spain

            Run scheduled task as local user group (not BUILTIN)