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
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.
-
No problem buddy! Just remember to mark the answer so other people know it works. Feb 7, 2018 at 7:36