I noticed very strange behaviour of my device.
I create a new intent with action MediaStore.ACTION_IMAGE_CAPTURE
Then I start an activty for result. But at the moment I take a picture from the camera my application disappears from processes in DDMS perspective. Then in few seconds it is running again.
What is interesting - onActivityResult
is called properly and receives an image. But I have some singletones that contain some values in their fields. After process is restarted these singletones are re-initialized and lose all values.
There is no problem on other devices - neither tablets nor phones.
Is it a known bug? Ho to prevent process restarting on Galaxy Tab 2 10.1?
Thanks in advance!
UPDATE: Below is my code that starts camera intent
private void startCameraIntent() {
String timeStamp = new SimpleDateFormat("yyyyMMdd_HHmmss", Locale.US).format(new Date());
String imageFileName = JPEG_FILE_PREFIX + timeStamp + "_";
File albumFile;
if (Environment.MEDIA_MOUNTED.equals(Environment.getExternalStorageState())){
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.FROYO){
albumFile = new File (Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_PICTURES), FOLDER_NAME);
} else {
albumFile = new File(Environment.getExternalStorageDirectory()+CAMERA_DIR+FOLDER_NAME);
}
if (albumFile != null){
if (!albumFile.mkdirs()){
if (!albumFile.exists()){
showToast(getApplicationContext().getString(R.string.sFailedToCreateDirectory));
return;
}
}
}
File imageFile = null;
try {
imageFile = File.createTempFile(imageFileName, JPEG_FILE_SUFFIX, albumFile);
mCurrentPhotoPath = imageFile.getAbsolutePath();
} catch (IOException e) {
e.printStackTrace();
}
Intent cameraIntent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
cameraIntent.putExtra(MediaStore.EXTRA_OUTPUT, Uri.fromFile(imageFile));
fileUri = Uri.parse(mCurrentPhotoPath);
startActivityForResult(cameraIntent, ACTION_CAPTURE_IMAGE);
} else {
showToast(getApplicationContext().getString(R.string.sSDNotReady));
}
}