-
Notifications
You must be signed in to change notification settings - Fork 75
Description
Heyo, I'm having an issue where the GPS location is only being updated very occasionally, despite the fact that I have explicitly defined it as 0.5s (500ms).
My Code:
public class MainActivity extends AppCompatActivity {
public SimpleLocation location;
@Override
protected void onCreate(Bundle savedInstanceState) {
Context context = this;
boolean requireFine = false;
boolean passiveMode = false;
long updateInterval = 500;
boolean requireNew = true;
new SimpleLocation(context, requireFine, passiveMode, updateInterval, requireNew);
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
location = new SimpleLocation(this); // Initialise
if (!location.hasLocationEnabled()) {
// ask the user to enable location access
SimpleLocation.openSettings(this); // Open settings if the user hasn't put in location permissions.
}
location.beginUpdates();
TextView main = (TextView) findViewById(R.id.multitext);
main.setText("Epoch_ms, lat, long\n");
final Handler handler = new Handler();
handler.postDelayed(new Runnable() {
@Override
public void run() { // Loop forever with 1000ms delay
handler.postDelayed(this, 1000);
SimpleLocation.Point position = location.getPosition();
Log.d("Debug", "Running run");
main.append(((System.currentTimeMillis()) + "," + String.valueOf(position) + ";" + "\n"));
}},1000);
}
}
I'd expect it to output a different value every time it loops (as it should have updated at least twice by then) but it never seems to. It only prints the same value over and over again, however, it is a valid value. I have tried this both in my house, running, as well as in a car, with the same results. It seems if I leave it for a bit, then open the app, it's happy to grab my location, but doesn't update it as I move...
I'm testing it on an OPPO Reno Z (CPH1979) on ColorOS 11.1, and I've confirmed the app has all of the permissions granted, and have tried with both Course and fine, and both with requireNew=true and false.
Many thanks,
GhostDog98