action_image_capture重新启动应用

时间:2013-10-23 15:46:07

标签: android android-orientation android-camera-intent

我已经好几天都在寻找解决这个问题的方法,我不知道该怎么做:(

我有一个使用原生相机拍照的应用程序,但问题是,有时候,只有在某些设备中,当我拍照并保存并返回时,我的应用程序重新启动。

它是一个webview,它在服务器端提供了很多逻辑,但是使用javascript接口来处理本机功能,例如摄像头。

它非常难以捕捉,因为它只发生在某些设备中,即使它们是相同的型号,我有两个星系王牌,在一个几乎总是发生在另一个很少次(这些不是唯一的设备,我已经测试了)

我认为它与相机的方向或类似的东西有关。因为当我在保存/放弃屏幕中旋转设备(拍照后)时,似乎更经常发生

这是我的一些代码:

清单:

        <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

1 个答案:

答案 0 :(得分:0)

您能否在onActivityResult显示您的代码?

随机猜测:如果您在mPictureName中使用onActivityResult,那么如果活动在后台被销毁,则必须确保您的班级字段已恢复。

有关详细信息,请参阅该答案: capturing images with MediaStore.ACTION_IMAGE_CAPTURE intent in android