Webview does not allow me to select image


I have a hybrid app that works through a webview. I have solved the theme of pop-ups for the login of facebook or twitter. However, when you click on the < input type="file" / > nothing opens. I do not understand why. Can someone tell me if there is any way to open an input file to choose and upload an image from the webview?

Note: The website is in php, the webview only shows it and the app does not do anything more than that.

asked by Criss 17.06.2016 в 16:56

1 answer


The problem in this type of, specifically input.file is that due to Security does not allow its operation, it simply will not recognize it.

If you want to do something similar it would be implementing WebChromeClient () , this is an example:


public class MyAwesomeActivity extends Activity {

 private WebView wv;

 private ValueCallback<Uri> mUploadMessage;
 private final static int FILECHOOSER_RESULTCODE=1;

 protected void onActivityResult(int requestCode, int resultCode,
                                    Intent intent) {
   if (null == mUploadMessage) return;
            Uri result = intent == null || resultCode != RESULT_OK ? null
                    : intent.getData();
            mUploadMessage = null;


 public void onCreate(Bundle savedInstanceState) {

  wv = new WebView(this);
  wv.setWebViewClient(new WebViewClient());
  wv.setWebChromeClient(new WebChromeClient()
         //The undocumented magic method override
         //Eclipse will swear at you if you try to put @Override here
         public void openFileChooser(ValueCallback<Uri> uploadMsg) {

          mUploadMessage = uploadMsg;
          Intent i = new Intent(Intent.ACTION_GET_CONTENT);
          MyAwesomeActivity.this.startActivityForResult(Intent.createChooser(i,"File Chooser"), FILECHOOSER_RESULTCODE);


answered by 17.06.2016 в 18:20