alert()弹出

input的file现选择(特别说明:不同的android版本弹出的样式不同,选择文件后自动上传)

webView.setWebChromeClient(new WebChromeClient() { 
//支持alert弹出 
@Override 
public boolean onJsAlert(WebView view, String url, String message, 
JsResult result) { 
return super.onJsAlert(view, url, message, result); 

@Override 
public boolean onJsConfirm(WebView view, String url, 
String message, JsResult result) { 
return super.onJsConfirm(view, url, message, result); 

//webView中支持input的file现选择 
 // For Android 3.0+ 
        public void openFileChooser(ValueCallback<Uri> uploadMsg, String acceptType) {   
               if (mUploadMessage != null) return; 
               mUploadMessage = uploadMsg;    
               Intent i = new Intent(Intent.ACTION_GET_CONTENT); 
               i.addCategory(Intent.CATEGORY_OPENABLE); 
               i.setType("*/*"); 
                   startActivityForResult( Intent.createChooser( i, "File Chooser" ), Util.FILECHOOSER_RESULTCODE ); 
                } 
            // For Android < 3.0 
        public void openFileChooser(ValueCallback<Uri> uploadMsg) { 
               openFileChooser( uploadMsg, "" ); 
        } 
        // For Android  > 4.1.1 
      public void openFileChooser(ValueCallback<Uri> uploadMsg, String acceptType, String capture) { 
              openFileChooser(uploadMsg, acceptType); 
      }

    1. @Override
    2. protected   void  onActivityResult( int  requestCode,  int  resultCode,
    3. Intent intent) {
    4. if (requestCode==FILECHOOSER_RESULTCODE)
    5. {
    6. if  ( null  == mUploadMessage)  return ;
    7. Uri result = intent ==  null  || resultCode != RESULT_OK ?  null
    8. : intent.getData();
    9. mUploadMessage.onReceiveValue(result);
    10. mUploadMessage =  null ;
    11. }
    12. }

最新文章

  1. JS 小数的常用处理方法
  2. 继承的小DEMO
  3. [课程设计]Sprint One 总结&amp;发表评论&amp;团队贡献分
  4. 纯css径向渐变(CSS3--Gradient)
  5. FZU 2218 Simple String Problem(简单字符串问题)
  6. log4j 分类输出
  7. Chrome浏览器下调试SASS
  8. 详解Asp.net MVC DropDownLists
  9. chardet安装
  10. &#39;Invalid update: invalid number of rows in section xx. The number of rows contained in an existing section after the update (xxx)...
  11. error:stray&amp;#39;\243&amp;#39;in program
  12. javascript中的数组对象
  13. Swift:一个简单的货币转换器App在iOS10中的分析和完善
  14. Python基础之面向对象2(封装)
  15. ubuntu14/16 安装python3-opencv3_百度经验
  16. 爬取qq号
  17. python 基础篇
  18. 从零开始一起学习SLAM | 你好,点云
  19. 原生js,通过document.getElementByClassName获取元素的索引值
  20. Python自动化开发 - 装饰器

热门文章

  1. HDU 5813 Elegant Construction (贪心)
  2. Gym 100507H Pair: normal and paranormal (贪心)
  3. thymeleaf中的th:with用法
  4. poj 1517 u Calculate e
  5. C#一些知识点:委托和事件的区别
  6. Centos6.3 jekyll环境安装
  7. 正则表达式(Regular Expression)
  8. Android学习笔记(3)
  9. 自定义的带tab的可左右滑动的viewpager之二viewpager与fragment不兼容
  10. Python的包管理工具Pip