1

Possible Duplicate:
File Upload in WebView

I have an Advanced WebView that need to allow users to upload images or files from their device. The code is not giving any errors however it is not working either. Any assistance is appreciated.

private ValueCallback<Uri>                      mUploadMessage;
private final static int FILECHOOSER_RESULTCODE = 1;
@Override
protected void onActivityResult(int requestCode, int resultCode,
        Intent intent) {
    if (requestCode == FILECHOOSER_RESULTCODE) {
        if (null == mUploadMessage)
            return;
        Uri result = intent == null || resultCode != RESULT_OK ? null
                : intent.getData();
        mUploadMessage.onReceiveValue(result);
        mUploadMessage = null;
    }
}

class MyWebChromeClient extends WebChromeClient {


    public void openFileChooser(ValueCallback<Uri> uploadMsg) {

        mUploadMessage = uploadMsg;
        Intent i = new Intent(Intent.ACTION_GET_CONTENT);
        i.addCategory(Intent.CATEGORY_OPENABLE);
        i.setType("image/*");
        RunHTML5WebView.this.startActivityForResult(
                Intent.createChooser(i, "Image Browser"),
                FILECHOOSER_RESULTCODE);
    }
}
Community
  • 1
  • 1
Kazuko Ando
  • 207
  • 4
  • 17
  • I've no particular knowledge of HTML5 and what you are wanting to achieve but I do know that if your app does not have the correct permissions set in the Manifest, Android will fail silently i.e. you will get no error message. If you are accessing memory card, camera etc as your data source does your app have the appropriate permissions? – D-Dᴙum Sep 16 '11 at 19:53
  • Actually it is an advanced webview for an online dating site. What I am wanting to do is allow the webview to upload photo's from either the internal memory or memory card. – Kazuko Ando Sep 16 '11 at 23:21
  • @Kazuko Ando, have you fixed this issue.i'm facing similar problem if you found any solution for this... – Senthil Mg Feb 10 '12 at 04:46
  • Have you solved this issue? I have the same issue. – CsharpBeginner Sep 28 '12 at 15:43

0 Answers0