<span style=
"font-size:12px"
>
public
boolean
onShowFileChooser(WebView webView, ValueCallback<Uri[]> filePathCallback, WebChromeClient.FileChooserParams fileChooserParams) {
dn.dnLog(
"d"
,
"For Android 5.0+"
);
if
(mFilePathCallback !=
null
)
mFilePathCallback.onReceiveValue(
null
);
mFilePathCallback = filePathCallback;
Intent takePictureIntent =
new
Intent(MediaStore.ACTION_IMAGE_CAPTURE);
if
(takePictureIntent.resolveActivity(getPackageManager()) !=
null
) {
File photoFile =
null
;
try
{
photoFile = createImageFile();
takePictureIntent.putExtra(
"PhotoPath"
, mCameraPhotoPath);
}
catch
(IOException ex) {
dn.dnLog(
"d"
,
" Unable to Image File "
);
ex.printStackTrace();
}
if
(photoFile !=
null
) {
mCameraPhotoPath =
"file:"
+ photoFile.getAbsolutePath();
takePictureIntent.putExtra(MediaStore.EXTRA_OUTPUT, Uri.fromFile(photoFile));
}
else
{
takePictureIntent =
null
;
}
}
Intent contentSelectionIntent =
new
Intent(Intent.ACTION_GET_CONTENT);
contentSelectionIntent.addCategory(Intent.CATEGORY_OPENABLE);
contentSelectionIntent.setType(
"image/*"
);
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,
"Image Chooser"
);
chooserIntent.putExtra(Intent.EXTRA_INITIAL_INTENTS, intentArray);
startActivityForResult(chooserIntent, INPUT_FILE_REQUEST_CODE);
return
true
;
}</span>