Android WebView File Upload

后端 未结 5 1703
灰色年华
灰色年华 2020-12-02 12:48

I am developing an Android app. Basically it is a WebView and a progressBar. Facebook\'s mobile site (m.facebook.com) is loaded into the WebView.

5条回答
  •  攒了一身酷
    2020-12-02 13:07

    Given the high number of votes I'm guessing no one has noticed the 3rd comment (from David Esteves) contains a link with to answer to this question.

    Michel Olivier said:

    This solution also works for Honeycomb and Ice Cream Sandwich. Seems like Google introduced a cool new feature (accept attribute) and forgot to to implement an overload for backwards compatibility.

    So you just need to add a openFileChooser overload to your MyWebChromeClient class that accepts the string parameter and then call the one that does not:

    public void openFileChooser( ValueCallback uploadMsg, String acceptType ) 
    {  
        this.openFileChooser(uploadMsg);
    }
    

    Doing this I was able to make your code run as intended.

提交回复
热议问题