我的网络视图有一个网站,要求用户上传图片,但从图库中选择图像后,网络视图无法识别onActivity
结果。
代码:
webView.loadUrl(URL)
webView.webChromeClient = object: WebChromeClient() {
override fun onShowFileChooser(webView:WebView, filePathCallback: ValueCallback<Array<Uri>>, fileChooserParams: FileChooserParams):Boolean {
var mFilePathCallback = filePathCallback
val intent = Intent(Intent.ACTION_GET_CONTENT)
intent.setType("*/*")
val PICKFILE_REQUEST_CODE = 100
startActivityForResult(intent, PICKFILE_REQUEST_CODE)
return true
}
}
fun onActivityResult(requestCode: Int, resultCode: Int,
intent: Intent,
mFilePathCallback: Any): Boolean {
var PICKFILE_REQUEST_CODE = null
if (requestCode == PICKFILE_REQUEST_CODE)
{
val result = if (intent == null || resultCode != RESULT_OK)
null
else
intent.getData()
val resultsArray = arrayOfNulls<Uri>(1)
resultsArray[0] = result
mFilePathCallback.onReceiveValue(resultsArray)
}
return true
}