PhoneGap的摄像头的Andr​​oid杀死科尔多瓦 [英] Phonegap camera android kills cordova

查看:98
本文介绍了PhoneGap的摄像头的Andr​​oid杀死科尔多瓦的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我工作的几个PhoneGap的项目。在他们中的一些,我使用的相机功能。

I'm working on several Phonegap projects. In some of them I'm using the camera functions.

我这个问题百思不得其解(从PhoneGap的文档):

I'm puzzling with this issue (from the Phonegap documentation):

Android的怪癖

Android Quirks

Android使用意图启动摄像头活动装置上   捕捉图像,并在手机上的低内存,科尔多瓦活动   可能会被杀死。在这种情况下,图像可能不会出现在   科尔多瓦活性得以恢复。

Android uses intents to launch the camera activity on the device to capture images, and on phones with low memory, the Cordova activity may be killed. In this scenario, the image may not appear when the cordova activity is restored.

我在上不断我的测试设备的一个这个问题(HTC One X的)。这是相当充分,这么好来测试这一点。

I'm having this problem on one of my test devices constantly (HTC One X). It's quite full, so good to test this.

我注意到有另一种插件:<一href="https://$c$c.google.com/p/foreground-camera-plugin/">https://$c$c.google.com/p/foreground-camera-plugin/针对此问题。但我会尽量避免尽可能多的插件......(可移植到其他平台轻松)。 而且它是可达到的PhoneGap 2.4.0,我正与PhoneGap的2.9.0

I noticed there is an alternative plugin: https://code.google.com/p/foreground-camera-plugin/ for this problem. But I try to avoid plugins as much as possible... (to be portable to other platforms easily). And it's available up to Phonegap 2.4.0 and I'm working with Phonegap 2.9.0

我已经使用的文件URI,而不是数据(以避免内存问题)。

I already use the file URI and not the Data (to avoid the memory problem).

我的问题是:没有任何人知道,当Android的决定杀掉其他的活动(如科尔多瓦,这是非常需要的PhoneGap)。在什么级别的空闲内存? (百分比,MB)。所以,我可以提前检查并警告用户。

My question is: does anybody know when Android decides to kill other activities (like Cordova, which is quite needed for Phonegap). On what level of free memory? (percentage, MB). So I could check this in advance and warn the user.

我当然希望这个问题得到解决...但它似乎并没有很快得到解决......

Of course I hope this issue gets resolved... but it doesn't seem to be resolved soon....

的第一句话后修改

我不打算解决真正的问题,我发现这不是真的有可能。这是Android和PhoneGap的之间的事情。我只需要知道它是否有可能向用户发出警告会出现这种情况。因此,用户可以杀掉一些,然后再继续其他的应用程序......所以,当发生这种情况?什么时候的Andr​​oid觉得没有足够的内存来让这件事怎么回事?这是我的问题。

I've no intention resolving the real problem, I've found out that's not really possible. It's a thing between Android and Phonegap. I just need to know whether it's possible to warn the user this will happen. So the user can kill some of the other apps before continuing... So when does this occur? When does android think there is not enough memory to get this thing going on? That's my question.

修改2013 11月29日

由AustinAllover给出的链接,因为,我现在知道这是不是只是一个PhoneGap的问题... Android相机似乎杀死情况太少存储器的所有Java应用程序......这样的问题比PhoneGap的更通用的/科尔多瓦只有...

Because of the link given by AustinAllover, I now know this is not just a Phonegap issue... The Android camera seems to kill all Java apps in case of too few memory... so the question is more generic than Phonegap/Cordova only...

推荐答案

不知道是否存在一个很好的回答你的问题,但我会努力。

Not sure if there exists a good answer to your question but I will try.

这取决于好几个因素,当应用程序被杀掉来释放内存。第一,主要因素是多少相机活动需要运行。 相机应用程序本身是大多数设备(虽然它而异)10MB左右。这是在存储器中的应用程序的大小,而不是在运行的活动,这将是逻辑上有点大时所花费的大小。它也取决于相机本身和存储实际相片所需要的内存量上,让我们假设该照片是围绕4MB时存储,并且围绕20MB原料。这让我们的 30MB 作为应用程序运行的大致上限,虽然是炒作,我稍后会检查这个自己进行编辑。

It depends on quite a few factors when apps get killed to free memory. First and major factor is how much the camera activity needs to run. The camera app itself is on most devices (though it varies) around 10MB. This is the size of the app in memory and not the size it takes when running the activity, which would be logically a bit bigger. It also depends on the camera itself and the amount of memory needed to store the actual photo, lets assume the photo is around 4MB when stored, and raw around 20MB. This gives us an approximate upper limit of 30MB for the app running, though is speculation and I will check this myself later and edit it.

有关内存一个很好的参考到Android,你可以在这里找到的 https://01.org/android-ia/user-guides/android-memory-tuning-android-5.0-and-5.1 他们的意见,总是有 500MB 或更多的内存来运行应用程序,这当然是你正在运行的所有应用程序不是一个特定的应用程序。

A good reference about memory related to Android you can find here https://01.org/android-ia/user-guides/android-memory-tuning-android-5.0-and-5.1 They advice to always have 500MB or more memory available to run apps, this is of course for all apps you are running and not for one specific app.

比GC的开始删除的应用程序,从存储器中的点,这种情况非常接近存储器的实际边界,当不到5%仍是自由的,该值emperical由我自己的实验。首先,它杀死仍处于高速缓存中,但不再需要的应用程序,只是它杀死那些应用程序作为最后的手段积极为好。

Than the point that GC starts removing apps from memory, this happens very close to the actual bounds of the memory, when less than 5% is still free, this value is emperical by my own experiments. First it kills apps that are still in cache but not longer required, only as last resort it kills apps that are active as well.

我的假设是,你的应用程序将在下面杀死约50MB内存免费的,但我要强调的是,有很多假设,在这里和那里是告诉你每个设备与各种相机的一个很好的答案没有通用的方法而每个Android版本。

My assumption is that your app will be killed below approximately 50MB of memory free, though I have to stress that there are many assumptions here and there is no general way to tell you a good answer for each device with each kind of camera and each version of Android.

希望它能帮助,怕没有。

Hope it helps, fear it does not.

这篇关于PhoneGap的摄像头的Andr​​oid杀死科尔多瓦的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆