import java.lang.ref.WeakReference;
import java.util.*;
+import java.io.*;
import android.Manifest;
import android.app.Activity;
public static final int MSG_UPDATE_AGE = 2;
public static final int MSG_IDLE_MODE = 3;
public static final int MSG_IGNITER_STATUS = 4;
+ public static final int MSG_FILE_FAILED = 5;
// Intent request codes
public static final int REQUEST_CONNECT_DEVICE = 1;
ad.idle_mode = (Boolean) msg.obj;
ad.update_state(null);
break;
+ case MSG_FILE_FAILED:
+ ad.file_failed((File) msg.obj);
+ break;
}
}
};
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() {
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);
}
}
}
+ boolean fail_shown;
+
+ private void file_failed(File file) {
+ if (!fail_shown) {
+ fail_shown = true;
+ AlertDialog fail = new AlertDialog.Builder(this).create();
+ fail.setTitle("Failed to Create Log File");
+ fail.setMessage(file.getPath());
+ fail.setButton(AlertDialog.BUTTON_NEUTRAL, "OK",
+ new DialogInterface.OnClickListener() {
+ public void onClick(DialogInterface dialog, int which) {
+ dialog.dismiss();
+ }
+ });
+ fail.show();
+ }
+ }
+
@Override
public boolean onCreateOptionsMenu(Menu menu) {
MenuInflater inflater = getMenuInflater();