I am trying implement the filechooser of my webpage in my webview. I am getting 'SIGABRT' error while using showFileChooser(ValueCallback uploadMsg, String acceptType) in my webview. when I get the result from intent and set the filepath in the callback method "ValueCallback.onRecieveValue('file address here')". Below is the code snippet.`
public void showFileChooser(ValueCallback<String[]> uploadMsg, String acceptType) {
mUploadMessage1 = uploadMsg;
File imageStorageDir = new File(Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_PICTURES)
, "AndroidExampleFolder");
if (!imageStorageDir.exists()) {
// Create AndroidExampleFolder at sdcard
imageStorageDir.mkdirs();
}
// Create camera captured image file path and name
File file = new File(imageStorageDir + File.separator + "IMG_" + String.valueOf(System.currentTimeMillis()) + ".jpg");
mCapturedImageURI = Uri.parse("file:"+Uri.fromFile(file).getPath());
// Camera capture image intent
final Intent captureIntent = new Intent(android.provider.MediaStore.ACTION_IMAGE_CAPTURE);
captureIntent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
captureIntent.putExtra(MediaStore.EXTRA_OUTPUT, mCapturedImageURI);
Intent i = new Intent(Intent.ACTION_GET_CONTENT);
i.putExtra(Intent.EXTRA_ALLOW_MULTIPLE, true);
i.addCategory(Intent.CATEGORY_OPENABLE);
i.setType("image/*");
// Create file chooser intent
Intent chooserIntent = Intent.createChooser(i, "Image Chooser");
// Set camera intent to file chooser
chooserIntent.putExtra(Intent.EXTRA_INITIAL_INTENTS, new Parcelable[]{captureIntent});
// On select image call onActivityResult method of activity
startActivityForResult(chooserIntent, FILECHOOSER_RESULTCODE);
}
OnActivityresult:
data.getData();
result = Uri.parse("file:" + getPath(HealthRecord.this, data.getData()));
mUploadMessage1.onReceiveValue(new String[]{result.toString()});
User contributions licensed under CC BY-SA 3.0