8

Fixed: "Do not keep activities" is default on SG3

Samsung Galaxy S3 ships with "Do not keep Activities" on by default (test models in two locations were both having this fault out the box)

Of course this means that as soon as any other activity is started, including from within your Cordova/PhoneGap app, your app's main activity will be destroyed. Any callback events will obviously never fire.

Switching the option off fixes the problem.

Check developer options regardless of brand/model, for example Asus Nexus 7 tablets do not have this default.


I've setup a basic test app. Which has a button and an img tag + the unmodified Cordova index.js

Button onclick is calling capturePhoto():

function onPhotoURISuccess(imageURI) {
  console.log(imageURI);
  var largeImage = document.getElementById('largeImage');
  largeImage.style.display = 'block';
  largeImage.src = imageURI;
}

function capturePhoto() {
  navigator.camera.getPicture( onPhotoURISuccess, onFail, 
     { quality: 20, allowEdit: true, destinationType: Camera.DestinationType.FILE_URI });
}

function onFail(message) {
  alert('Failed because: ' + message);
}

When I run the app on the simulator and also on a Asus Nexus 7 Tablet, the Camera opens as expected, allows a photo to be taken and confirmed, and then returns with the FILE_URI and sets the image src attribute.

However on a Samsung Galaxy SIII, (we are testing with two in different locations) the Camera opens, allows a capture, and after confirmation, attempts to resume the test app and dies.

Does anyone know of this problem, and is there a way to fix it?

FYI, I've added an extra setting to the AndroidManifest.xml activity node : android:screenOrientation="nosensor" - although this doesn't solve the issue (clutching at straws here.)

Other info:

  • Phone is running Android 4.1.2
  • Targetting sdk 16
  • Cordova v 2.4.0rc1

Tested versions of phonegap - 1.8 - 2.4rc (all crash or fail to return image.)

Relevant portion of the stacktrace is here: http://pastie.org/5974920

Update

  • regarding Simon MacDonald's suggestion.

Tested with quality : 100

Same results as before.

  • 1.9-2.1 bomb (no message)
  • 2.2-2.3 get back to the app, but no image.
  • 2.4 - sorry the app has stopped - "managed" crash

None working.

4

3 回答 3

7

在三星 Galaxy 3上,默认情况下,开发人员选项“不保留活动”处于启用状态。

当您启动任何其他活动时,这将垃圾收集您的主要活动,在这种情况下是相机。

关闭该选项可以解决问题。

于 2013-03-25T22:40:21.080 回答
2

我有一个三星 Galaxy Note II。我有同样的问题。我在 AndroidManifest.xml 中更改了它,现在它适用于三星和 HTC Thunderbolt

<uses-feature android:name="android.hardware.camera" android:required="false"/>

<uses-sdk android:minSdkVersion="7" android:targetSdkVersion="10"/>

<activity  android:configChanges="orientation|keyboardHidden" />
于 2013-03-06T20:18:32.787 回答
1

您是否关闭了后台进程?如果是这样,这将破坏所有 Android 相机。在意图中传回的数据不能为空。

此外,请务必将其添加到您的 Android 清单中:

android:configChanges="orientation|keyboardHidden|keyboard|screenSize|locale"  

2.4.x 崩溃的事实是一个错误,因为在这种情况下处理恢复状态的东西坏了,但事实是您需要后台进程将数据从一个意图传递到另一个意图,否则这将不适用于任何安卓应用。我们至少开始优雅地处理这种情况。我认为关闭应用程序可能是一个错误,所以我有兴趣在这里看到一张票:https ://issues.apache.org/jira/browse/CB

更新:见https://issues.apache.org/jira/browse/CB-2533

于 2013-02-07T21:55:05.103 回答