Java 谷歌硬盘文件上传在Android Webview中不起作用
我正在将文件上传到WebView。 本地文件运行良好。但谷歌硬盘上的文件不起作用。 本地文件的URI信息不为空。(非空) 本地文件:content://com.android.providers.downloads.documents/document/xxx 谷歌驱动器文件:content://com.google.android.apps.docs.storage/document/xxx 这是我的密码Java 谷歌硬盘文件上传在Android Webview中不起作用,java,android,html,file-upload,android-webview,Java,Android,Html,File Upload,Android Webview,我正在将文件上传到WebView。 本地文件运行良好。但谷歌硬盘上的文件不起作用。 本地文件的URI信息不为空。(非空) 本地文件:content://com.android.providers.downloads.documents/document/xxx 谷歌驱动器文件:content://com.google.android.apps.docs.storage/document/xxx 这是我的密码 ... takeFileResultLauncher = register
...
takeFileResultLauncher = registerForActivityResult(new ActivityResultContracts.StartActivityForResult(), result -> {
int resultCode = result.getResultCode();
if (resultCode == RESULT_OK) {
Intent intent = result.getData();
Fragment fragment = getSupportFragmentManager().findFragmentByTag(FileChooserDialog.class.getSimpleName());
if (fragment instanceof DialogFragment) {
((DialogFragment) fragment).dismiss();
}
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
if (null == uploadValueCallBack) {
return;
}
if (intent != null) {
Uri uri = intent.getData();
intent.setData(uri);
}
uploadUris = WebChromeClient.FileChooserParams.parseResult(resultCode, intent);
uploadValueCallBack.onReceiveValue(uploadUris);
uploadValueCallBack = null;
} else if (null != uploadMessage) {
Uri resultUri = (intent == null) ? null : intent.getData();
uploadMessage.onReceiveValue(resultUri);
uploadMessage = null;
}
}
});
...
Intent i = new Intent(Intent.ACTION_GET_CONTENT);
i.addCategory(Intent.CATEGORY_OPENABLE);
String[] fileMimeTypes = {
"application/pdf",
"application/zip",
"image/*",
};
i.setType("*/*");
i.putExtra(EXTRA_MIME_TYPES, fileMimeTypes);
takeFileResultLauncher.launch(Intent.createChooser(i, "File Chooser"));
...
我不知道发生的原因。
也许我需要查看网页
请帮帮我…:(