Handling input type file in android webview – source code included

Published by Kapil Mohan on

File input type in android web view doesn’t directly open the file explorer, this needs to be manually handled. The example illustrates using a web view for loading file input type.

Source code includes activity for Loading web view, with codes going backward, uploading a file with permission request and bug fixes. Includes a splash activity and no network dialog for beginners, splash activity can be replaced with a splash screen that changes with activity load.

Instructions for using source code

  • if you are using as complete source code, then change the base_url to your URL in strings.xml
  • Change logo in drawable to your logo.
  • Change app_name and title_activity_start to your website/app name.

Fixed an issue with the unexpected crashing of app while, exiting file explorer without choosing an image.

Requires permission to Read and write storage,Internet and optionally for camera

Example includes progress bar for status, can be skipped and directly use your desigsn.


Include base url in strings, if required.


  • we need to provide permission for accessing storage. Here both in manifest and runtime permission is provided.
  • override onShowFileChooser of WebChromeClient class to handle file chooser .
  • Here we are providing simple example for directly accessing explorer, this can be replaced with bottomsheet for providing options like camera,gallery etc…
  • Save valueCallBack uri to a global variable, and assign its value on activity result, when intent returns the uri of selected item.

Kapil Mohan

Like to add color to developers life and apps. Can create smile using Android, iOS, PHP, codeignitor, web technologies, etc... Feel free to contact me at [email protected] .