您的位置:首页 > 移动开发

Webview 打开本地图片库兼容问题

2016-05-17 18:05 363 查看
今天遇到问题,在Android5.1.1版本,H5页面无法调用本地图片,查看接口发现,现在使用openFileChooser方法,兼容几个版本,如下:

// Andorid 4.1+
@SuppressWarnings("unused")
public void openFileChooser(ValueCallback<Uri> uploadFile,
String acceptType, String capture) {

}

// Andorid 3.0 +
@SuppressWarnings("unused")
public void openFileChooser(ValueCallback<Uri> uploadFile,
String acceptType) {

}

// Android 3.0
@SuppressWarnings("unused")
public void openFileChooser(ValueCallback<Uri> uploadFile) {

}

发现无法使用,于是查看api发现,在5.1.1版本使用的是onShowFileChooser方法,放上去,运行,ok可以打开,解决此问题。

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

}

第一次留底做纪念,希望能帮到其他的机油!!!
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  android webview