HTML输入类型“文件"在android的webview上不起作用.有什么办法可以使用webview android上传文件吗? [英] HTML input type 'file' is not working on webview in android. Is there any way to upload file using webview android?
本文介绍了HTML输入类型“文件"在android的webview上不起作用.有什么办法可以使用webview android上传文件吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
这是我的html浏览代码.
this is my browsing code of html.
这是我的android代码,它加载html文件以供浏览文件并上传到服务器上.
This is my android code which load html file for browse file and upload on server.
runOnUiThread(new Runnable() {
@Override
public void run() {
// TODO Auto-generated method stub
System.out.println(AndroidConstants.MAIN_URL());
toast(AndroidConstants.MAIN_URL());
webView.loadUrl(AndroidConstants.MAIN_URL());
webView.setDownloadListener(new DownloadListener() {
@Override
public void onDownloadStart(String url, String userAgent,
String contentDisposition, String mimetype,
long contentLength) {
// TODO Auto-generated method stub
Intent i = new Intent(Intent.ACTION_VIEW);
i.setData(Uri.parse(url));
startActivity(i);
}
public void openFileChooser(ValueCallback<Uri> uploadMsg) {
Intent i = new Intent(Intent.ACTION_GET_CONTENT);
i.addCategory(Intent.CATEGORY_OPENABLE);
i.setType("image/*");
WebViewActivity.this.startActivityForResult(Intent.createChooser(i,"Image Chooser"), 2533);
}
public void openFileChooser(ValueCallback<Uri> uploadMsg, String acceptType) {
openFileChooser(uploadMsg);
}
public void openFileChooser(ValueCallback<Uri> uploadMsg, String acceptType, String capture) {
openFileChooser(uploadMsg);
}
});
}
});
JavaScriptInterface jsInterface = new JavaScriptInterface(this);
webView.getSettings().setJavaScriptEnabled(true);
我想在Android应用程序上使用html5上传视频文件.
i want upload video file using html5 on android application.
推荐答案
This issue has already been asked and answered here: File Upload in WebView
也请检查以下内容: https://code.google.com/p/android/issues/detail ?id = 62220
Also check this: https://code.google.com/p/android/issues/detail?id=62220
您可以使用此类: https://github.com/delight-im/Android- AdvancedWebView
这篇关于HTML输入类型“文件"在android的webview上不起作用.有什么办法可以使用webview android上传文件吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文