Android APIs
public static abstract class

WebChromeClient.FileChooserParams

extends Object
java.lang.Object
   ↳ android.webkit.WebChromeClient.FileChooserParams

Summary

Constants
int MODE_OPEN Open single file.
int MODE_OPEN_MULTIPLE Like Open but allows multiple files to be selected.
int MODE_SAVE Allows picking a nonexistent file and saving it.
Public Constructors
WebChromeClient.FileChooserParams()
Public Methods
abstract Intent createIntent()
Creates an intent that would start a file picker for file selection.
abstract String[] getAcceptTypes()
Returns an array of acceptable MIME types.
abstract String getFilenameHint()
The file name of a default selection if specified, or null.
abstract int getMode()
Returns file chooser mode.
abstract CharSequence getTitle()
Returns the title to use for this file selector, or null.
abstract boolean isCaptureEnabled()
Returns preference for a live media captured value (e.g.
static Uri[] parseResult(int resultCode, Intent data)
Parse the result returned by the file picker activity.
[Expand]
Inherited Methods
From class java.lang.Object

Constants

public static final int MODE_OPEN

Added in API level 21

Open single file. Requires that the file exists before allowing the user to pick it.

Constant Value: 0 (0x00000000)

public static final int MODE_OPEN_MULTIPLE

Added in API level 21

Like Open but allows multiple files to be selected.

Constant Value: 1 (0x00000001)

public static final int MODE_SAVE

Added in API level 21

Allows picking a nonexistent file and saving it.

Constant Value: 3 (0x00000003)

Public Constructors

public WebChromeClient.FileChooserParams ()

Added in API level 21

Public Methods

public abstract Intent createIntent ()

Added in API level 21

Creates an intent that would start a file picker for file selection. The Intent supports choosing files from simple file sources available on the device. Some advanced sources (for example, live media capture) may not be supported and applications wishing to support these sources or more advanced file operations should build their own Intent.

 How to use:
 1. Build an intent using createIntent()
 2. Fire the intent using startActivityForResult(Intent, int).
 3. Check for ActivityNotFoundException and take a user friendly action if thrown.
 4. Listen the result using onActivityResult(int, int, Intent)
 5. Parse the result using parseResult(int, Intent) only if media capture was not requested.
 6. Send the result using filePathCallback of onShowFileChooser(WebView, ValueCallback, WebChromeClient.FileChooserParams)
 

Returns
  • an Intent that supports basic file chooser sources.

public abstract String[] getAcceptTypes ()

Added in API level 21

Returns an array of acceptable MIME types. The returned MIME type could be partial such as audio/*. The array will be empty if no acceptable types are specified.

public abstract String getFilenameHint ()

Added in API level 21

The file name of a default selection if specified, or null.

public abstract int getMode ()

Added in API level 21

Returns file chooser mode.

public abstract CharSequence getTitle ()

Added in API level 21

Returns the title to use for this file selector, or null. If null a default title should be used.

public abstract boolean isCaptureEnabled ()

Added in API level 21

Returns preference for a live media captured value (e.g. Camera, Microphone). True indicates capture is enabled, false disabled. Use getAcceptTypes to determine suitable capture devices.

public static Uri[] parseResult (int resultCode, Intent data)

Added in API level 21

Parse the result returned by the file picker activity. This method should be used with createIntent(). Refer to createIntent() for how to use it.

Parameters
resultCode the integer result code returned by the file picker activity.
data the intent returned by the file picker activity.
Returns
  • the Uris of selected file(s) or null if the resultCode indicates activity canceled or any other error.