gpt4 book ai didi

Android : 5. 0 : WebChromeClient. FileChooserParams无法解析为类型

转载 作者:搜寻专家 更新时间:2023-11-01 08:41:42 26 4
gpt4 key购买 nike

为了上传文件,我正在尝试使我的 webview 与 android 5.0 兼容。我的构建目标是 API19 4.4.2。我已经下载了 5.0 sdk 及其依赖项。我收到错误 WebChromeClient.FileChooserParams 无法解析为类型

我在 Stackoverflow 上找到了这段代码。

  webView = (WebView) findViewById(R.id.webView1);

webView.setWebChromeClient(new WebChromeClient() {
public boolean onShowFileChooser(
WebView webView, ValueCallback<Uri[]> filePathCallback,
WebChromeClient.FileChooserParams fileChooserParams) {

// Double check that we don't have any existing callbacks
if(mFilePathCallback != null) {
mFilePathCallback.onReceiveValue(null);
}
mFilePathCallback = filePathCallback;

// Set up the take picture intent
Intent takePictureIntent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
if (takePictureIntent.resolveActivity(MainActivity.this.getPackageManager()) != null) {
// Create the File where the photo should go
File photoFile = null;
try {
photoFile = createImageFile();
takePictureIntent.putExtra("PhotoPath", mCameraPhotoPath);
} catch (IOException ex) {
// Error occurred while creating the File
Log.e(TAG, "Unable to create Image File", ex);
}

// Continue only if the File was successfully created
if (photoFile != null) {
mCameraPhotoPath = "file:" + photoFile.getAbsolutePath();
takePictureIntent.putExtra(MediaStore.EXTRA_OUTPUT,
Uri.fromFile(photoFile));
} else {
takePictureIntent = null;
}
}

// Set up the intent to get an existing image
Intent contentSelectionIntent = new Intent(Intent.ACTION_GET_CONTENT);
contentSelectionIntent.addCategory(Intent.CATEGORY_OPENABLE);
contentSelectionIntent.setType("image/*");

// Set up the intents for the Intent chooser
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;
}
});

问题 enter image description here

最佳答案

WebChromeClient.FileChooserParams 是 API 级别 21 的新方法,onShowFileChooser() 方法也是如此。

因此,您需要将 compileSdkVersion(也就是 Eclipse 中的“构建目标”)设置为 21,否则将无法识别这些符号。

关于Android : 5. 0 : WebChromeClient. FileChooserParams无法解析为类型,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31988861/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com