In onShowFileChooser(WebView view, ValueCallback<Uri[]> filePath, WebChromeClient.FileChooserParams fileChooserParams)
function gives filePath
to null;
Device configuration:
Debug-infos:
Android version: 21
Device: samsung SM-N9005
OS Version: 3.4.0-6408191(N9005DXSGBQA1)
Device: hlte
In other devices and api level it is working fine.
webView.setWebChromeClient(new WebChromeClient() {
// For Android 5.0
public boolean onShowFileChooser(WebView view, ValueCallback<Uri[]> filePath, WebChromeClient.FileChooserParams fileChooserParams) {
//qrCodeReaderView.stopCamera();
mFilePathCallback = filePath;
Intent takePictureIntent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
File photoFile = null;
try {
photoFile = createImageFile();
} catch (IOException e) {
e.printStackTrace();
}
mCapturedImageURI = Uri.fromFile(photoFile);
if (photoFile != null) {
takePictureIntent.putExtra(MediaStore.EXTRA_OUTPUT, mCapturedImageURI
);
} else {
}
startActivityForResult(takePictureIntent, INPUT_FILE_REQUEST_CODE);
return true;
}
});
On activity result:
@Override public void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
mFilePathCallback.onReceiveValue(new Uri[]{mCapturedImageURI});
mFilePathCallback = null;
}
Logcat:
java.lang.RuntimeException:
Unable to resume activity
{com.gaintz/com.shashank.gaintz.WebViewActivity}:
java.lang.RuntimeException: Failure delivering result ResultInfo{who=null, request=1, result=-1, data=null} to activity {com.gaintz/com.shashank.gaintz.WebViewActivity}:
java.lang.NullPointerException: Attempt to invoke interface method 'void android.webkit.ValueCallback.onReceiveValue(java.lang.Object)' on a null object reference at android.app.ActivityThread.performResumeActivity(ActivityThread.java:3390) at