Action_image_capture reloads the application

I have been looking for a solution to this problem for several days, and I do not know what to do: (

I have an application that uses its own camera for shooting, but the problem is that sometimes and only on some devices, when I took a photo and saved it and returned, my application restarts.

Its web browsing is so large that it is done on the server side, but uses the javascript interface for a built-in handle function, such as a camera.

It is very difficult to catch, because this happens only in some devices, even if they are the same model, I have two aces of the galaxy, and in one they almost always happen, and in the others there are very few (these are not the only devices that I tested)

I think this is due to the orientation of the camera or something like that. Since this happens more often when I rotate the device on the save / reset screen (after shooting)

This is my code:

manifest:

        <activity
        android:name="XXX"
        android:configChanges="orientation|keyboardHidden|screenSize"
        android:excludeFromRecents="false"
        android:label="@string/XXX"
        android:launchMode="singleTask"
        android:taskAffinity=""
        android:windowSoftInputMode="adjustPan" >
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />

            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
    </activity>

camera.class

        public void showNativeCamera(){

         // create Intent to take a picture and return control to the calling application
        Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);


        UUID uniqueKey = UUID.randomUUID();
        mPictureName = "img_" + uniqueKey.toString() + ".jpg"; 
        fileUri = getOutputMediaFileUri(MEDIA_TYPE_IMAGE); // create a file to save the image
        Log.d("amanda", "file uri: " + fileUri);
        intent.putExtra(MediaStore.EXTRA_OUTPUT, fileUri); // set the image file name


        intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);

        // start the image capture Intent
        mParent.startActivityForResult(intent, CAPTURE_IMAGE_ACTIVITY_REQUEST_CODE);
    }

Logcat:

10-23 13:42:45.250: V/CropImage(12042): Crop = no, Return = specified uri
10-23 13:42:45.257: D/PowerManagerService(1528): acquireWakeLock flags=0x1 tag=ActivityManager-Launch
10-23 13:42:45.265: V/CropImage(12042): onPause
10-23 13:42:45.273: D/PowerManagerService(1528): acquireWakeLock flags=0x1 tag=SCREEN_FROZEN
10-23 13:42:45.273: I/WindowManager(1528): Setting rotation to 1, animFlags=1
10-23 13:42:45.289: I/ActivityManager(1528): Config changed
10-23 13:42:45.375: D/PowerManagerService(1528): releaseWakeLock flags=0x1 tag=SCREEN_FROZEN
10-23 13:42:45.406: E/ClockWidget(11247): clock_bg portrait
10-23 13:42:45.406: E/ClockWidget(11247): drawDayText
10-23 13:42:45.406: E/ClockWidget(11247): width= 50
10-23 13:42:45.406: E/ClockWidget(11247): widthText= 72.0
10-23 13:42:45.406: E/ClockWidget(11247): RIGHT
10-23 13:42:45.421: V/Camera(11982): --onActivityResult--requestCode: 2001
10-23 13:42:45.421: V/Camera(11982): --onActivityResult--resultCode: -1
10-23 13:42:45.421: V/Camera(11982): --onActivityResult--data: Intent { act=inline-data (has extras) }
10-23 13:42:45.453: V/CropImage(12042): onDestroy
10-23 13:42:45.914: D/PowerManagerService(1528): acquireWakeLock flags=0x1 tag=ActivityManager-Launch
10-23 13:42:45.921: W/ActivityManager(1528): Duplicate finish request for
10-23 13:42:45.929: D/PowerManagerService(1528): acquireWakeLock flags=0x1 tag=SCREEN_FROZEN
10-23 13:42:45.929: I/WindowManager(1528): Setting rotation to 0, animFlags=1
10-23 13:42:45.937: I/ActivityManager(1528): Config changed
10-23 13:42:46.023: E/ClockWidget(11247): clock_bg portrait
10-23 13:42:46.023: E/ClockWidget(11247): drawDayText
10-23 13:42:46.023: E/ClockWidget(11247): width= 50
10-23 13:42:46.023: E/ClockWidget(11247): widthText= 72.0
10-23 13:42:46.023: E/ClockWidget(11247): RIGHT
10-23 13:42:46.054: D/PowerManagerService(1528): releaseWakeLock flags=0x1 tag=SCREEN_FROZEN
10-23 13:42:46.210: I/ApplicationPackageManager(12075): cscCountry is not German : ANC
10-23 13:42:46.218: D/amanda(12075): onCreate() called
10-23 13:42:46.281: I/webclipboard(12075): clipservice: android.sec.clipboard.ClipboardExManager@4052c190
10-23 13:42:46.398: V/geo aca(12075): pklsajdf
10-23 13:42:46.398: V/geo aca(12075): android.location.LocationManager@405378d0
10-23 13:42:46.406: V/acastart(12075): lpm
10-23 13:42:46.414: V/asd(12075): [network, passive, gps]
10-23 13:42:46.421: D/androidNlpServiceThread(8458): adding listener com.google.android.location.internal.client.NetworkLocationClient$1@405a5b48 with period 45
10-23 13:42:46.421: D/androidNetworkLocationListeners(8458): Still have listener com.google.android.location.internal.client.NetworkLocationClient$1@405a5b48
10-23 13:42:46.421: D/WifiService(1528): [mPersistState] : On
10-23 13:42:46.421: D/PowerManagerService(1528): acquireWakeLock flags=0x1 tag=NetworkLocationLocator
10-23 13:42:46.421: D/PowerManagerService(1528): acquireWakeLock flags=0x1 tag=WifiService
10-23 13:42:46.421: D/PowerManagerService(1528): releaseWakeLock flags=0x1 tag=WifiService
10-23 13:42:46.437: D/androidNlpServiceThread(8458): adding listener com.google.android.location.internal.client.NetworkLocationClient$1@405a5b48 with period 45
10-23 13:42:46.437: D/androidNetworkLocationListeners(8458): Still have listener com.google.android.location.internal.client.NetworkLocationClient$1@405a5b48
10-23 13:42:46.437: D/PowerManagerService(1528): acquireWakeLock flags=0x1 tag=RILJ
10-23 13:42:46.445: D/PowerManagerService(1528): releaseWakeLock flags=0x1 tag=RILJ
10-23 13:42:46.453: E/wpa_supplicant(4553): Ongoing Scan action...
10-23 13:42:46.460: D/PowerManagerService(1528): acquireWakeLock flags=0x1 tag=RILJ
10-23 13:42:46.468: D/PowerManagerService(1528): releaseWakeLock flags=0x1 tag=RILJ
10-23 13:42:46.476: D/amanda(12075): onActivityResult() called
10-23 13:42:46.484: D/amanda(12075): onActivityResult error: null
+4
source share
1 answer

Can you show the code that you have in onActivityResult?

A random assumption: if you use mPictureNamein onActivityResult, then you must make sure that the field of your class will be restored if the action is destroyed when it is in the background.

See this answer for more info: capturing images with intent MediaStore.ACTION_IMAGE_CAPTURE in android

0

All Articles