X-Git-Url: https://git.gag.com/?a=blobdiff_plain;f=altosdroid%2Fapp%2Fsrc%2Fmain%2Fjava%2Forg%2Faltusmetrum%2FAltosDroid%2FAltosDroid.java;h=5caee5f87aab5323ea0032cf54f865649ff22a8b;hb=772b15425317d1da231c9925839320721cdb1269;hp=e564e78478612742fe29eb5112bc16eb77f5c7a5;hpb=528fdc4e03466430c8d81fc78c90d3c9e8465ca7;p=fw%2Faltos diff --git a/altosdroid/app/src/main/java/org/altusmetrum/AltosDroid/AltosDroid.java b/altosdroid/app/src/main/java/org/altusmetrum/AltosDroid/AltosDroid.java index e564e784..5caee5f8 100644 --- a/altosdroid/app/src/main/java/org/altusmetrum/AltosDroid/AltosDroid.java +++ b/altosdroid/app/src/main/java/org/altusmetrum/AltosDroid/AltosDroid.java @@ -630,7 +630,7 @@ public class AltosDroid extends FragmentActivity implements AltosUnitsListener, mStateView = (TextView) findViewById(R.id.state_value); mAgeView = (TextView) findViewById(R.id.age_value); mAgeNewColor = mAgeView.getTextColors().getDefaultColor(); - mAgeOldColor = getResources().getColor(R.color.old_color, getTheme()); + mAgeOldColor = getResources().getColor(R.color.old_color); } private void ensureBluetooth() { @@ -742,14 +742,23 @@ public class AltosDroid extends FragmentActivity implements AltosUnitsListener, private void enable_location_updates() { // Listen for GPS and Network position updates LocationManager locationManager = (LocationManager) this.getSystemService(Context.LOCATION_SERVICE); - locationManager.requestLocationUpdates(LocationManager.GPS_PROVIDER, 1000, 1, this); - location = locationManager.getLastKnownLocation(LocationManager.GPS_PROVIDER); + if (locationManager != null) + { + try { + locationManager.requestLocationUpdates(LocationManager.GPS_PROVIDER, 1000, 1, this); + location = locationManager.getLastKnownLocation(LocationManager.GPS_PROVIDER); + } catch (Exception e) { + locationManager.requestLocationUpdates(LocationManager.NETWORK_PROVIDER, 1000, 1, this); + location = locationManager.getLastKnownLocation(LocationManager.NETWORK_PROVIDER); + } - if (location != null) - AltosDebug.debug("Resume, location is %f,%f\n", - location.getLatitude(), - location.getLongitude()); + if (location != null) + AltosDebug.debug("Resume, location is %f,%f\n", + location.getLatitude(), + location.getLongitude()); + AltosDebug.debug("Failed to get GPS updates\n"); + } update_ui(telemetry_state, state, true); }