通过WebView上传问题android

时间:2014-05-14 21:42:25

标签: java android android-webview

我目前有这个基于webview的Android应用程序,我目前的目标是能够通过webview上传图像。但是,当我单击Intellij中的“调试按钮”时,我现在处于一种奇怪的情况,当我点击“调试按钮”时,它在我点击上传按钮时运行完美,它显示了要从上传中选择的应用程序。但是,当我签署Apk并构建它并准备好发布它停止工作时,我检查了应用程序遇到的错误,并说明:

 java.lang.SecurityException: Permission Denial: get/set setting for user asks to run as user -2 but is calling from user 0; this requires android.permission.INTERACT_ACROSS_USERS_FULL
        at com.android.server.am.ActivityManagerService.handleIncomingUser(ActivityManagerService.java:13140)
        at android.app.ActivityManager.handleIncomingUser(ActivityManager.java:2038)
        at com.android.providers.settings.SettingsProvider.callFromPackage(SettingsProvider.java:607)
        at android.content.ContentProvider$Transport.call(ContentProvider.java:279)
        at android.content.ContentProviderNative.onTransact(ContentProviderNative.java:273)
        at android.os.Binder.execTransact(Binder.java:388)
        at dalvik.system.NativeStart.run(Native Method)

所以我尝试修复它所做的是添加它在清单中请求的权限,但是没有用。以下是我目前用于尝试通过webview上传文件的代码

 @Override
protected void onActivityResult(int requestCode, int resultCode,
                                Intent intent) {
    if (requestCode == FILECHOOSER_RESULTCODE) {
        if (null == mUploadMessage)
            return;
        Uri result = intent == null || resultCode != RESULT_OK ? null
                : intent.getData();
        mUploadMessage.onReceiveValue(result);
        mUploadMessage = null;

    }
}

 public void openFileChooser(ValueCallback<Uri> uploadMsg) {

                mUploadMessage = uploadMsg;
                Intent i = new Intent(Intent.ACTION_GET_CONTENT);
                i.addCategory(Intent.CATEGORY_OPENABLE);
                i.setType("image/*");
                main.this.startActivityForResult(Intent.createChooser(i,"Image Chooser"), FILECHOOSER_RESULTCODE);
            }

            public void openFileChooser(ValueCallback<Uri> uploadMsg, String acceptType) {
                openFileChooser(uploadMsg);
            }

            public void openFileChooser(ValueCallback<Uri> uploadMsg, String acceptType, String capture) {
                openFileChooser(uploadMsg);
            }

任何帮助都将非常感谢这是我第一次遇到此错误。顺便说一下,除了上面的代码之外,我的应用程序中的其他任何地方都没有调用“openFileChooser”。

0 个答案:

没有答案