Location sensor does not work again if it is turned on after being turned off


I am facing a strange behaviour related to location sensor. It works, I mean, I get GPS data, if one of these conditions happens:

  1. Smartphone GPS sensor is already on when I start my app
  2. If I turn on smarthpone GPS by Android configuration page

When my app is running properly (i.e., GPS data is available) and I turn off smartphone GPS sensor and then I turn it back on, GPS data is no more available, no matter how much time you will wait for.

Alsom if app if started when smartphone GPS sensor is off, GPS data won’t be provide if GPS sensor is activated.

How can I have GPS data available always when smartphone GPS sensor is on?

it’s best to use a battery-saving location, its fast than accurate, you use a timer to activate and deactivate it, beforehand you use permission first on the event

Do you mean to use Location_Sensor.enabled<-true and Location_Sensor.enabled<-false alternatively?

If so, Location_Sensor.enabled<-true doesn’t solve the problem I’ve described. Once the app operated with smartphone GPS sensor off, nothing I’ve tried programmatically made GPS data available again.

Save battery power is even desirable, but not mandatory.

The only way I know how to do this is through Tasker. You can use the tasker profile to set the gps to stay on when the screen is off. You can also use profiles to keep gps running while the app is open. try search google navigation

GPS does not become unavailable when screen is off, but when GPS is turned off and afterwards turned on.

use background,check this : ItoO - Background Tasks [special] 🥳
or this [FREE] Background Tasks: Itoo - Extensions - MIT App Inventor Community