Samsung Galaxy Tab 2 10.1 kills the process after taking pictures in the camera

I noticed a very strange behavior of my device.

I create a new intention with action MediaStore.ACTION_IMAGE_CAPTURE

Then I run the action for the result. But at the moment I'm taking a picture from the camera, my application disappears from the processes in the DDMS perspective. Then after a few seconds it will start again.

What is interesting is that it is onActivityResultcalled correctly and receives an image. But I have some singletones that contain some values ​​in their fields. After restarting the process, these single elements are reinitialized and lose all values.

There are no problems on other devices - neither tablets, nor phones.

Is this a known bug? Ho, to prevent the process from restarting on the Galaxy Tab 2 10.1?

Thanks in advance!

UPDATE: Below is my code that runs the 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));
    }
}
+3
source share
1 answer

Is this a known bug?

It's not a mistake. If your application is not in the foreground, its process can be interrupted at any time.

Ho, to prevent the process from restarting on the Galaxy Tab 2 10.1?

You can not. Your process may disappear at any time when it is not in the foreground. For example, if a user presses HOME and then Android completes the process, and after that the user tries to return to your application through the list of recent tasks, you will see the same behavior. Your application should be able to handle this.

Camera , , . , , .

+1

All Articles