2

I tried a lot to upload file through WebView but I not getting success, but its working only 5.0 Devices.

Google Chrome Browser handling all the things & working fine in all devices.

public class MyWebChromeClient extends WebChromeClient {

    public boolean onShowFileChooser(WebView view, ValueCallback<Uri[]> filePath, FileChooserParams fileChooserParams) {

        mFilePathCallback = filePath;

        Intent intent = new Intent(Intent.ACTION_GET_CONTENT);
        intent.addCategory(Intent.CATEGORY_OPENABLE);
        intent.setType("*/*");
        startActivityForResult(intent, PICKFILE_REQUEST_CODE);
   return true;

    }

    public void openFileChooser( ValueCallback uploadMsg, String acceptType ) {
        mUploadMessage = uploadMsg;
        Intent i = new Intent(Intent.ACTION_GET_CONTENT);
        i.addCategory(Intent.CATEGORY_OPENABLE);
        i.setType("*/*");
        startActivityForResult(
                Intent.createChooser(i, "File Browser"),
                PICKFILE_REQUEST_CODE);
    }

    //For Android 4.1
    public void openFileChooser(ValueCallback<Uri> uploadMsg, String acceptType, String capture){
        mUploadMessage = uploadMsg;
        Intent i = new Intent(Intent.ACTION_GET_CONTENT);
        i.addCategory(Intent.CATEGORY_OPENABLE);
        i.setType("*/*");
        startActivityForResult( Intent.createChooser( i, "File Chooser" ), PICKFILE_REQUEST_CODE );

    }
Asif Patel
  • 1,744
  • 1
  • 20
  • 27
Narendra Sorathiya
  • 3,770
  • 2
  • 34
  • 37

0 Answers0