android openfilechooser方法未调用已签名的apk

android openfilechooser方法未调用已签名的apk,android,apk,signed,Android,Apk,Signed,我在android openFileChooser方法上面临一个问题。如果使用eclipse通过adb将其安装到手机(三星galaxy s3搭载安卓4.0.3)上,效果会很好。但是,如果我从ecplise导出一个签名的apk并将其安装到手机中,openFileChooser方法将不会调用 我的html代码: input type='file' name='files[]' multiple accept='image/*' 我在eclipse中的代码: private class mainWe

我在android openFileChooser方法上面临一个问题。如果使用eclipse通过adb将其安装到手机(三星galaxy s3搭载安卓4.0.3)上,效果会很好。但是,如果我从ecplise导出一个签名的apk并将其安装到手机中,openFileChooser方法将不会调用

我的html代码:

input type='file' name='files[]' multiple accept='image/*'
我在eclipse中的代码:

private class mainWebChromeClient extends WebChromeClient {

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

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

         public void openFileChooser(ValueCallback<Uri> uploadMsg) {

                final List<Intent> cameraIntents = new ArrayList<Intent>();
                final Intent captureIntent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
                File externalDataDir = Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DCIM);
                File cameraDataDir = new File(externalDataDir.getAbsolutePath()+File.separator+"vast_manager_camera");
                if(!cameraDataDir.exists()){
                    cameraDataDir.mkdirs();
                }

                filePath = cameraDataDir.getAbsolutePath()+File.separator+System.currentTimeMillis()+".jpg";
                Uri imageUri = Uri.fromFile(new File(filePath));

                final PackageManager packageManager = getPackageManager();
                final List<ResolveInfo> listCam = packageManager.queryIntentActivities(captureIntent, 0);

                final Intent intent = new Intent(captureIntent);

                for(ResolveInfo res : listCam) {
                    final String packageName = res.activityInfo.packageName;
                    intent.setComponent(new ComponentName(res.activityInfo.packageName, res.activityInfo.name));
                    intent.setPackage(packageName);
                    intent.putExtra(MediaStore.EXTRA_OUTPUT, imageUri);
                    cameraIntents.add(intent);

                }


                VastActivity.mUploadMessage = uploadMsg;

                Intent i = new Intent(Intent.ACTION_GET_CONTENT);

                i.addCategory(Intent.CATEGORY_OPENABLE);
                i.setType("image/*");               
                Intent chooserIntent = Intent.createChooser(i,"Image Chooser");

                chooserIntent.putExtra(Intent.EXTRA_INITIAL_INTENTS, cameraIntents.toArray(new Parcelable[]{}));
                VastActivity.this.startActivityForResult(chooserIntent, FILECHOOSER_RESULTCODE);

         }
 }
私有类mainWebChromeClient扩展WebChromeClient{
@抑制警告(“未使用”)
public void openFileChooser(ValueCallback uploadMsg、字符串接受类型、字符串捕获){
openFileChooser(上传消息);
}
@抑制警告(“未使用”)
public void openFileChooser(ValueCallback uploadMsg,String acceptType){
openFileChooser(上传消息);
}
public void openFileChooser(ValueCallback uploadMsg){
最终列表cameraIntents=newarraylist();
最终意图捕获意图=新意图(MediaStore.ACTION\u IMAGE\u捕获);
文件externalDataDir=Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY\u DCIM);
File cameraDataDir=新文件(externalDataDir.getAbsolutePath()+File.separator+“vast\u manager\u camera”);
如果(!cameraDataDir.exists()){
cameraDataDir.mkdirs();
}
filePath=cameraDataDir.getAbsolutePath()+File.separator+System.currentTimeMillis()+“.jpg”;
uriimageuri=Uri.fromFile(新文件(filePath));
最终PackageManager PackageManager=getPackageManager();
最终列表listCam=packageManager.QueryInputActivities(captureIntent,0);
最终意图=新意图(captureIntent);
用于(ResolveInfo res:listCam){
最后一个字符串packageName=res.activityInfo.packageName;
setComponent(新组件名(res.activityInfo.packageName,res.activityInfo.name));
intent.setPackage(packageName);
intent.putExtra(MediaStore.EXTRA_输出,imageUri);
添加(意图);
}
VastActivity.mUploadMessage=上传消息;
意向i=新意向(意向.行动\u获取\u内容);
i、 addCategory(意图。类别可打开);
i、 setType(“image/*”);
Intent chooserint=Intent.createChooser(i,“图像选择器”);
选择content.putExtra(Intent.EXTRA_INITIAL_INTENTS,cameraIntents.toArray(新包裹[]{}));
VastActivity.this.startActivityForResult(选择内容、文件选择器\u结果代码);
}
}

我在这个问题上挣扎了几天,但没有解决它的想法(T.T),任何人请帮助我解决它。

如果您使用了proguard,那么“openFileChooser”方法可能有点模糊,请尝试添加

-keep class*扩展了android.webkit.


转到proguard配置,看看是否有帮助:)

我也遇到了同样的问题。将此添加到我的proguard-project.txt文件为我修复了它:

-keepclassmembers class * {
    public void openFileChooser(android.webkit.ValueCallback,java.lang.String);
    public void openFileChooser(android.webkit.ValueCallback);
    public void openFileChooser(android.webkit.ValueCallback, java.lang.String, java.lang.String);
}