java - (Webview) Android 捕获的图像保存不工作某些版本
问题描述
我正在做一个 webview 应用程序。我的网站上有一个表格,需要通过表格上传图片。我通过 file_input 选择相机,拍照,但是当我返回时,我看到图像没有保存在文件输入中。不工作的版本(我不知道全部):Android 10,Android 7。运行版本:Android 9,Android 5。我只是后端 Web 开发人员,我不太擅长移动编程。最后; 下面的代码返回 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;
}
我从相机捕获图像,但输入文件如下:在此处输入图像描述
解决方案
推荐阅读
- python - 如何将列表的两个元素之间的值作为新列表返回
- javascript - 如果我已经有相似多边形的中心,那么计算多边形中心的更优雅的方法
- amazon-web-services - 在 AWS 中,单个 VPC 有 2 个或更多 CIDR 块的用例是什么?
- image - 如何从文件服务器获取 docker 映像到我的本地注册表中?
- java - 在 VS Code 中运行的 Spring Boot 应用程序中接收空对象
- c# - Moq C#调用方法来测试
- javascript - 在 Facebook Messenger webview 弹出窗口中打开时如何关闭 Shiny 应用程序?
- r - 在 sapply R 中使用函数
- flask - 在 pythoneverywhere 上导入模型时出现 Flask Import 错误
- javascript - 生成 Nuxt 静态页面时没有图片或 api