2

I am working on app in which I have to take permission for location i.e GPS and Phone State.But after allowing permission I want to restart Activity as everything setup nicely..because I have Backend services to run after location permission..and service is not activating if location permission is not granted..so How can i do this? so in this way when I allow permission so app should restart or reset itself to start service..Kindly help me!

1 Answer 1

5

You could do

stopSelf();

after you have the permissions and then call

startActivity(new Intent(this, this.getClass()));

to restart the Activity.

A more elagant solution to your problem would be to use the method: onRequestPermissionsResult() Which runs when the user presses allow and start the service from there.

1
  • No problem buddy! Just remember to mark the answer so other people know it works. Feb 7, 2018 at 7:36

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.