Workaround for file uploads on Android 4.4 using reflection

前端 未结 1 1656
一向
一向 2021-02-10 17:17

From Android 4.1 to Android 4.3, you could subclass WebChromeClient on Android and implement the following (hidden, thus no @Override) method:

相关标签:
1条回答
  • 2021-02-10 17:53

    If you're looking for a clean solution to do this this without using tricky Javascript codes and detectors. I'd recommend using a Webview alternative.

    Crosswalk
    I'd recommend this. It'll work similar to the official webview. It's open source and made by the same people behind ChromeView. They've got a great setup guide: https://crosswalk-project.org/documentation/embedding_crosswalk.html

    Check it out: https://crosswalk-project.org/

    Chromium Webview
    Also inspired by ChromeView. They claim to have integrated the same API's as the official webview for easy migration. But they indicate that the Webview still might be a bit unstable.

    Check it out: https://github.com/mogoweb/chromium_webview

    GeckoView
    Made by Mozilla. Here's a demo project that uses it. Mozilla warns: "This is not a drop webview replacement and very unstable", but it has file upload

    Check it out: https://wiki.mozilla.org/Mobile/GeckoView

    If you're open on using Javascript (perhaps usefull for others) try:

    Kitkat Webview
    It uses javascript to enable file upload in KitKat webview do this. The demo allows you to upload an image, but you should be able to edit it to fit your needs.

    Check it out: https://github.com/henrychuangtw/Kitkat-WebView

    0 讨论(0)
提交回复
热议问题