【发布时间】:2019-08-11 04:51:43
【问题描述】:
在我的 Cordova 项目中,我依靠使用 ng-file-upload 的第三方依赖项来上传文件。
如issue on their Github 中所述,它适用于 iOS,但不适用于 Android。
由于有以下解决方案,旧问题已关闭:
https://github.com/apache/cordova-plugin-file-transfer#deprecated => 现已弃用
人行横道 => 现已弃用
我该如何解决这个问题?根本没有发送 HTTP 请求。
其他信息:
No activity found to handle file chooser intent.:
android.content.ActivityNotFoundException: No Activity found to handle
Intent { act=android.intent.action.GET_CONTENT cat=
[android.intent.category.OPENABLE] typ=.jpg,.png,.tiff,.jpeg,.tif,.pdf }
日志说明:
The error is telling you that the device has no applications installed that are able to handle that particular implicit intent. -> 但事实并非如此
- 这似乎不是权限问题:
当我使用
<input type="file" />代替 ng-file-upload 指令时,(Cordova)Android 应用程序可以工作。
(我们已经提供了所有必需的权限:)
<custom-config-file parent="/*" target="AndroidManifest.xml">
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.MANAGE_DOCUMENTS" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
</custom-config-file>
我将我的 config.xml 中的所有内容都列入了白名单,以用于 cordova:访问、允许导航、允许意图、CSP。还是没有运气。
我们无法控制 Android 代码(除非我们编写自定义插件)。这个原生代码能解决这个问题吗?
MyWebviewSettings.setJavaScriptCanOpenWindowsAutomatically(true);
MyWebviewSettings.setJavaScriptEnabled(true);
myWebView.getSettings().setJavaScriptEnabled(true);
myWebView.getSettings().setAllowFileAccessFromFileURLs(true);
myWebView.getSettings().setAllowUniversalAccessFromFileURLs(true);
【问题讨论】:
-
我会给任何帮助我们解决这个问题的人提供 50 代表奖励。谢谢:)
-
更新:有人告诉我有人设法使用 inappbrowser 使 ng-file-upload 工作。试试看..
标签: android cordova ionic-framework hybrid-mobile-app ng-file-upload