I'm doing a webview application. I have a form on my site and an image upload process is required via the form. I select the camera via file_input, take the photo, but when I go back I see that the image is not saved in file input. Versions not working (I don't know all): Android 10, Android 7. Running versions: Android 9, Android 5. Im just back-end web developer, im not very good at mobile programming. Finally; The code below returns null.
takePictureIntent.resolveActivity(activity_ismi.this.getPackageManager()) // returns null
//For Android 5.0+
@SuppressLint("QueryPermissionsNeeded")
public boolean onShowFileChooser(
WebView webView, ValueCallback<Uri[]> filePathCallback,
WebChromeClient.FileChooserParams fileChooserParams){
if(mUMA != null){
mUMA.onReceiveValue(null);
}
mUMA = filePathCallback;
Intent takePictureIntent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
if(takePictureIntent.resolveActivity(customActivity.this.getPackageManager()) == null){
File photoFile = null;
try{
photoFile = createImageFile();
takePictureIntent.putExtra("PhotoPath", mCM);
}catch(IOException ex){
Log.e(TAG, "failed to create image", ex);
}
}
Intent contentSelectionIntent = new Intent(Intent.ACTION_GET_CONTENT);
contentSelectionIntent.addCategory(Intent.CATEGORY_OPENABLE);
contentSelectionIntent.setType("*/*");
Intent[] intentArray;
if(takePictureIntent != null){
intentArray = new Intent[]{takePictureIntent};
}else{
intentArray = new Intent[0];
}
Intent chooserIntent = new Intent(Intent.ACTION_CHOOSER);
chooserIntent.putExtra(Intent.EXTRA_INTENT, contentSelectionIntent);
chooserIntent.putExtra(Intent.EXTRA_TITLE, "Please select");
chooserIntent.putExtra(Intent.EXTRA_INITIAL_INTENTS, intentArray);
startActivityForResult(chooserIntent, FCR);
return true;
}
I captured image from camera but input file this like:enter image description here