0

The need is something like this :

If there is Location Permission Enable, Have to check that GPS is enable or not,

If GPS is enable it's fine to continue for further flow - this working fine.

But, If GPS is not enable, Requesting to enable it from the settings.

Now, here when user comes back from Settings, onActivityResult() method will be called and further flow will be continue.

The Issue is as below :

The whole above process I need to do in onResume() because I have to autoconnect a hardware device even if the appuser comes back from the recent. (on pause - I have disconnected the hardware)

So, When I coming back from enabling GPS on, onResume() method calling again and the code is executing again.

Is there any better way to handle this?

Thanks.

Jaimin Modi
  • 1,530
  • 4
  • 20
  • 72
  • 2
    You can keep one flag for track that it's now come back from setting. If found come back from setting then don't call this work flow. – Poran Nov 25 '21 at 10:23
  • Like you're saying, if you leave the app to enable GPS, ``onResume`` runs again because that's what happens when the app comes back to the foreground. So do you really need to handle anything in ``onActivityResult``? You're already checking if GPS is enabled in ``onResume`` - if the user went to the settings and enabled it, your code will always see that it's enabled and be able to continue, right? – cactustictacs Nov 25 '21 at 16:29

0 Answers0