/** * Any time we are paused we need to save away the current state, so it will be restored correctly * when we are resumed. */ @Override protected void onPause() { if (reverseGeocoderTask != null) { reverseGeocoderTask.cancel(true); } final String selectedCategories = getSelectedCategories(); SharedPreferences.Editor editor = getPreferences(0).edit(); editor.putString("title", mIncidentTitle.getText().toString()); editor.putString("description", mIncidentDesc.getText().toString()); editor.putString("location", mIncidentLocation.getText().toString()); editor.putString("latitude", mLatitude.getText().toString()); editor.putString("longitude", mLongitude.getText().toString()); if (selectedCategories != null) { editor.putString("categories", selectedCategories); } editor.putString("photo", Preferences.fileName); editor.commit(); // Notify user that report has been saved as draft. if (draft) { Util.showToast(this, R.string.message_saved_as_draft); } super.onPause(); }
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.incident_add); // load settings Preferences.loadSettings(IncidentAdd.this); initComponents(); }
@Override protected void onActivityResult(int requestCode, int resultCode, Intent data) { super.onActivityResult(requestCode, resultCode, data); if (resultCode == RESULT_OK) { if (requestCode == REQUEST_CODE_CAMERA) { Uri uri = PhotoUtils.getPhotoUri("photo.jpg", this); Bitmap bitmap = PhotoUtils.getCameraPhoto(this, uri); PhotoUtils.savePhoto(this, bitmap); Log.i( CLASS_TAG, String.format("REQUEST_CODE_CAMERA %dx%d", bitmap.getWidth(), bitmap.getHeight())); } else if (requestCode == REQUEST_CODE_IMAGE) { Bitmap bitmap = PhotoUtils.getGalleryPhoto(this, data.getData()); PhotoUtils.savePhoto(this, bitmap); Log.i( CLASS_TAG, String.format("REQUEST_CODE_IMAGE %dx%d", bitmap.getWidth(), bitmap.getHeight())); } SharedPreferences.Editor editor = getPreferences(0).edit(); editor.putString("photo", PhotoUtils.getPhotoUri("photo.jpg", this).getPath()); editor.commit(); } }
/** * Upon being resumed we can retrieve the current state. This allows us to update the state if it * was changed at any time while paused. */ @Override protected void onResume() { this.setSavedReport(); getSharedText(); super.onResume(); }
@Override protected void onDestroy() { super.onDestroy(); stopLocating(); }