我一直在寻找这个问题的解决方案,但我不知道该怎么办:(
我有一个使用本机相机拍照的应用程序,但问题是,有时,并且仅在某些设备中,当我拍照并保存并返回时,我的应用程序会重新启动。
它是一个webview,它的大部分逻辑是在服务器端制作的,但使用javascript接口来处理相机等本机功能。
很难抓住它,因为它只发生在某些设备上,即使它们是相同的型号,我有两个 Galaxy ace,一个几乎总是发生,另一个很少发生(这些不是我测试过的唯一设备)
我认为这与相机的方向或类似的东西有关。因为当我在保存/丢弃屏幕中旋转设备时似乎更频繁地发生(拍照后)
这是我的一些代码:
显现:
<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>
相机类
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);
}
日志猫:
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