gpt4 book ai didi

android - Phonegap 视频捕捉崩溃

转载 作者:塔克拉玛干 更新时间:2023-11-02 23:39:45 25 4
gpt4 key购买 nike

我制作了一个相对简单的 phonegap 应用程序,能够捕获图像和视频并将它们上传到服务器。

图像工作正常,但是当我调用捕捉视频时,相机 UI 出现,当我接受视频时,应用程序崩溃并在 logcat 中显示此错误:

java.lang.RuntimeException: Failure delivering result ResultInfo(who=null, request=2, result=-1, data=Intent { dat=content://media/external/video/media/46536 }} to activity {myApp.test.app}: java.lang.IllegalStateException:Do not perform IO operations on the UI thread. Use CordovaInterface.getThreadPool() instead

我使用的是 phonegap 3.0.0,我已经通过命令行界面安装了正确的插件,我的 AndroidManifest 没问题。

我正在使用来自 phonegap API 的演示代码,所以问题也不存在。

最佳答案

此问题的解决方法是编辑 [yourApp]\plugins\org.apache.cordova.media-capture\src\android\Capture.java

从第 377 行开始,更改此代码

private JSONObject createMediaFile(Uri data) {
File fp = webView.getResourceApi().mapUriToFile(data);
JSONObject obj = new JSONObject();

到下面的代码

private JSONObject createMediaFile(Uri data) {
// is thread checking enabled?
boolean thC = webView.getResourceApi().isThreadCheckingEnabled();
// set thread checking to disabled (this works around mapUriToFile failing with IllegalStateException: Do not perform IO operations on the UI thread.
webView.getResourceApi().setThreadCheckingEnabled(false);
File fp = webView.getResourceApi().mapUriToFile(data);
// set thread checking back to whatever it was before the call above.
webView.getResourceApi().setThreadCheckingEnabled(thC);
JSONObject obj = new JSONObject();

这对我们有用,希望它能尽快得到妥善修复。

关于android - Phonegap 视频捕捉崩溃,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19183174/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com