PhoneGap的2.9.1 - 相机;崩溃是由于后台进程限制 [英] PhoneGap 2.9.1 - Camera; crashing due to background process limit

查看:231
本文介绍了PhoneGap的2.9.1 - 相机;崩溃是由于后台进程限制的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

所以经过大量的调查,我终于把我的应用程序能够恢复状态(我只是简单地修改了MainAcitivity.java onCreate方法,如果有一个保存包实例上加载活动杀恢复页)

so after a lot of investigation, I finally made my app able to resume state (I simply just modified the OnCreate method in the MainAcitivity.java to load a "restore" page on activity kill if there is a saved bundle instance)

我相信一旦我解决这个最后的问题,一切都会好的,我终于可以睡觉了。

I believe once I fix this final problem, all will be good and I can finally sleep.

我要如何在PhoneGap的一个摄像头的活动/意图的结果,一旦应用程序已被杀害了,由于后台进程限制或正在检查不保留活动的可能性,(我拥有的用户数量惊人已经启用了谁这些限制)

HOW do I get the Activity/Intent result from a Camera in PhoneGap once the app has been killed off due to the Background Processes limit or the possibility of "Do not keep activities being checked" (I have a surprising amount of users who have these restrictions enabled)

我想这可能是可能使相机保存在一个临时目录中的文件,然后我只是通过JavaScript传递URI作为散列URL(所以它会是这样的file:/// android_www /首页 - restore.html#URI_TO_IMAGE)

I thought it might be possible to make the camera save the file in a temp directory and then I just pass the URI through javascript as a hash url (so it'd be something like file:///android_www/index-restore.html#URI_TO_IMAGE)

但我唯一的问题是 - 如何甚至开始这PhoneGap的?我知道应该怎么做全部的寄托吧图像的临时存储和通过的onCreate检索位置

But my only issue is - How do I even begin this in PhoneGap? I know what to do for everthing bar the temp storage of the image and retrieving the location through onCreate

推荐答案

好吧终于成功了,写了哈克解决方案,但它的工作原理。

Ok finally managed it, wrote a hacky solution but it works.


  1. 我修改了CordovaInterface和CordovaActivity加入了一个名为getShared preF函数返回,可以在整个应用程序进行访问的共享preference。

  1. I modified the CordovaInterface and CordovaActivity by adding a function called "getSharedPref" which returns a shared preference that can be accessed throughout the app.

我修改相机启动强制存储的名称是根据什么都输入temp.jpg或temp.png,然后将其存储在preference内。

I modified Camera Launcher to force the stored name to be temp.jpg or temp.png depending on what ever input, then store it within the preference.

在MainActivity.java,我用this.getShared preF()如果一个包实例不为空,然后检查为重点。不幸的是,我可以在科尔多瓦分配变量的唯一方法是通过做

On the MainActivity.java, I use this.getSharedPref() if a bundle instance is not null, and then check for the key. Unfortunately the only way I could assign the variable in Cordova was by doing

super.loadUrl("javascript: var global_image = '" + file + "'");


然后我做了通常的程序添加的文件在我的程序,这一切工作至今!快乐的日子

then I did the usual routines to add the file in my program and it all work so far! Happy days

走下赛场,我可能会写一个插件来使用,使用super.loadUrl(文件:/// blablabla#+文件);似乎没有工作。

Down the track I will probably write a plugin to use, using super.loadUrl("file:///blablabla#" + file); didn't seem to work.

唯一的问题至今是图像不调整大小和旋转正确,我仍然需要实现这个的图片集锦但到目前为止好。

The only issues so far are that Images aren't resized and rotated correctly, and I still need to implement this for the PhotoGallery but so far so good.

编辑:
我已经成功地获取照片调整大小和重新定向:)下一个问题是实现它到照相馆现在 - intent.putExtra(android.provider.MediaStore.EXTRA_OUTPUT,文件);似乎并不适用的某些原因。

edit: I've managed to get the photos resized and re-orientated :) Next issue is implementing it onto the Photo Gallery now - intent.putExtra(android.provider.MediaStore.EXTRA_OUTPUT, file); doesn't seem to apply for some reason.

编辑:

最新更新 - 因此它原来后的应用程序似乎已崩溃,你仍然可以获得意图回来不管,所以修改源$ C ​​$ C更是现在自动调用一个全局JavaScript函数调用customRestore ,其中经过从意图收集的信息,然后通过添加照片的正常例行程序。

Latest update - so it turns out AFTER the App has seemingly "crashed", you still get the Intent back regardless, so modifying the source code even more it now auto-calls a global javascript function called "customRestore", which passes over information gathered from the intent and then goes through the normal routine of adding a photo.

这篇关于PhoneGap的2.9.1 - 相机;崩溃是由于后台进程限制的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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