我在android openFileChooser方法中遇到問題。它運作良好,如果通過使用eclipse通過ADB安裝到手機(三星Galaxy S3採用Android 4.0.3)。但是,如果我從ecplise導出簽署的APK,並把它安裝到我的手機,openFileChooser方法會不會喊。android openfilechooser方法不能調用已簽名的apk
我的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);
}
}
我對這個問題幾天的奮鬥,但不知道去解決它(TT),請人幫我解決它。