delight-im / delight-im/Android-SimpleLocation

Only Updating very occasionally, despite update interval being set to 500

Open
#41 2 comments 0 reactions 0 assignees View on GitHub
question
Dominant language
Java
Stars
199
Forks
73
PR merge metrics
No merged PRs in 30d

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

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.