File Upload in WebView

后端 未结 19 1883
旧巷少年郎
旧巷少年郎 2020-11-22 00:28

I have been struggling to upload files from WebView since last few days and there is no progress. I googled and implemented all suggested solutions but none works, like: sol

19条回答
  •  北海茫月
    2020-11-22 00:44

    I found that I needed 3 interface definitions in order to handle various version of android.

    public void openFileChooser(ValueCallback < Uri > uploadMsg) {
      mUploadMessage = uploadMsg;
      Intent i = new Intent(Intent.ACTION_GET_CONTENT);
      i.addCategory(Intent.CATEGORY_OPENABLE);
      i.setType("image/*");
      FreeHealthTrack.this.startActivityForResult(Intent.createChooser(i, "Image Chooser"), FILECHOOSER_RESULTCODE);
    }
    
    public void openFileChooser(ValueCallback < Uri > uploadMsg, String acceptType) {
      openFileChooser(uploadMsg);
    }
    
    public void openFileChooser(ValueCallback < Uri > uploadMsg, String acceptType, String capture) {
      openFileChooser(uploadMsg);
    }
    

提交回复
热议问题