本文介绍了Cordova /三星Galaxy SIII - 相机崩溃的应用程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

固定:不要保留活动是SG3上的默认设置



默认情况下,Samsung Galaxy S3附带了不要保留活动



当然,这意味着只要任何其他活动开始,包括从您的Cordova / PhoneGap应用程序,您的应用程序的主活动将被销毁。任何回调事件显然都不会触发。



关闭选项可解决问题。



的品牌/型号,例如Asus Nexus 7平板电脑没有此默认值。






app。其中有一个按钮和一个img标签+未修改的Cordova index.js



Button onclick正在调用 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);
}

当我在模拟器上运行应用程序以及一个华硕Nexus 7平板电脑,相机会按预期打开,允许拍摄并确认照片,然后返回FILE_URI并设置图像 src 属性。



然而,在三星Galaxy SIII上(我们在两个不同的位置测试),相机打开,允许捕获,并确认后,尝试恢复测试应用程序并死亡。



有没有人知道这个问题,有没有办法解决它?



FYI,我已经添加了额外的设置到 AndroidManifest.xml 活动节点: android:screenOrientation =nosensor - 虽然这不解决问题



其他信息:




  • 电话正在运行Android 4.1.2

  • 定位sdk 16

  • Cordova v 2.4.0rc1



测试版本的phonegap - 1.8 - 2.4rc(所有崩溃或无法返回图片。)



stacktrace的相关部分位于: a href =http://pastie.org/5974920> http://pastie.org/5974920



更新

$ b


测试使用 quality:100



与之前相同的结果。




  • 1.9-2.1炸弹(无讯息)

  • 2.2-2.3返回应用程式,但没有图片。

  • 2.4 - 抱歉应用已停止 - 托管崩溃



解决方案

在Samsung Galaxy 3上,开发人员选项不要保留活动默认。



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



关闭选项可解决问题。


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.

解决方案

On the Samsung Galaxy 3 the developer option Do not keep activities is on by default.

This will garbage collect your main activity when you launch any other, in this case the Camera.

Switching off the option solves the problem.

这篇关于Cordova /三星Galaxy SIII - 相机崩溃的应用程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-18 23:54