我想在webview.button上的clike按钮无法上传文件时在webview上导入上传文件
public class BookFullScreenViewActivity extends Activity {
private final static int FILECHOOSER_RESULTCODE=1;
private void CreateHTML5WebView() {
mWebView[i] = new HTML5WebView(this);
mWebView[i].setInitialScale(1);
mWebView[i].getSettings().setJavaScriptEnabled(true);
mWebView[i].setWebChromeClient(new MyNewWebChromeClient());
}
调用webview
class MyNewWebChromeClient extends WebChromeClient{
public void openFileChooser(ValueCallback<Uri> uploadMsg) {
mUploadMessage = uploadMsg;
Intent i = new Intent(Intent.ACTION_GET_CONTENT);
i.addCategory(Intent.CATEGORY_OPENABLE);
i.setType("image/*");
BookFullScreenViewActivity.this.startActivityForResult(
Intent.createChooser(i, "Image Browser"),
FILECHOOSER_RESULTCODE);
}
}
onActivity Result
@Override
protected void onActivityResult(int requestCode,int resultCode, Intent data) {
// TODO Auto-generated method stub
super.onActivityResult(requestCode, resultCode, data);
Intent s;
if (requestCode==FILECHOOSER_RESULTCODE) {
if (null == mUploadMessage) return;
Uri result = data == null || resultCode != RESULT_OK ? null
: data.getData();
mUploadMessage.onReceiveValue(result);
mUploadMessage = null;
}
}
单击按钮onwebview for uploadfile在logcat上显示错误
02-03 17:56:55.401: V/WebViewInputDispatcher(6456): blockWebkitDraw
lockedtrue
02-03 17:56:55.401: V/webview(6456): singleCursorHandlerTouchEvent -getEditableSupport FASLE
02-03 17:56:56.516: V/WebViewInputDispatcher(6456): blockWebkitDraw
02-03 17:56:56.516: V/WebViewInputDispatcher(6456): blockWebkitDraw lockedfalse
02-03 17:56:56.516: V/webview(6456): singleCursorHandlerTouchEvent -getEditableSupport FASLE
02-03 17:56:59.356: V/WebViewInputDispatcher(6456): blockWebkitDraw
02-03 17:56:59.356: V/WebViewInputDispatcher(6456): blockWebkitDraw lockedfalse
02-03 17:56:59.356: V/webview(6456): singleCursorHandlerTouchEvent -getEditableSupport FASLE
02-03 17:56:59.656: D/webview(6456): blockWebkitViewMessage= false