Google is committed to advancing racial equity for Black communities. See how.

OpenFileActivityBuilder

public class OpenFileActivityBuilder extends Object

This class was deprecated.
Use OpenFileActivityOptions instead.

A builder that is used to configure and display the open file activity. This activity displays files and folders from the user's Drive. The activity can be used to display all files in the Drive, not just those your application has access to. Your application will be given access to the selected file.

To display the activity, pass the result of build(GoogleApiClient) to #startIntentSenderForResult(). When the activity completes, a successful response will include an extra EXTRA_RESPONSE_DRIVE_ID with the selected DriveId.

Note: you cannot use #startActivity to invoke the activity. This will fail.

Constant Summary

String EXTRA_RESPONSE_DRIVE_ID A successful result will return an extra by this name which will contain the DriveId of the selected file.

Public Method Summary

IntentSender
build(GoogleApiClient apiClient)
Builds an IntentSender from the builder attributes that can be used to start the Open File activity using startIntentSenderForResult(IntentSender, int, Intent, int, int, int).
OpenFileActivityBuilder
setActivityStartFolder(DriveId folder)
Sets the folder that the Activity will display initially.
OpenFileActivityBuilder
setActivityTitle(String title)
Sets the title displayed in the activity.
OpenFileActivityBuilder
setMimeType(String[] mimeTypes)
Sets the MIME type filter which controls which kinds of files are selectable in the file picker.
OpenFileActivityBuilder
setSelectionFilter(Filter filter)
Sets the Filter that controls which files are selectable in the file picker.

Inherited Method Summary

Constants

public static final String EXTRA_RESPONSE_DRIVE_ID

A successful result will return an extra by this name which will contain the DriveId of the selected file.

Constant Value: "response_drive_id"

Public Methods

public IntentSender build (GoogleApiClient apiClient)

Builds an IntentSender from the builder attributes that can be used to start the Open File activity using startIntentSenderForResult(IntentSender, int, Intent, int, int, int).

This method requires authorization with at least one of the following scopes: SCOPE_FILE.

Parameters
apiClient The GoogleApiClient to service the call. The client must be connected before invoking this method.

public OpenFileActivityBuilder setActivityStartFolder (DriveId folder)

Sets the folder that the Activity will display initially. If not specified, it will default to the root of "My Drive".

public OpenFileActivityBuilder setActivityTitle (String title)

Sets the title displayed in the activity.

Parameters
title the title to set on the activity (may not be null)

public OpenFileActivityBuilder setMimeType (String[] mimeTypes)

Sets the MIME type filter which controls which kinds of files are selectable in the file picker. If neither this nor setSelectionFilter(Filter) method is called, all non-folder files will be selectable.

Note: this method cannot be used with setSelectionFilter(Filter), doing so will throw an IllegalStateException on build(GoogleApiClient).

Parameters
mimeTypes the mime types to show in the picker. May not be null. Passing a zero-length array is equivalent to not calling this method.

public OpenFileActivityBuilder setSelectionFilter (Filter filter)

Sets the Filter that controls which files are selectable in the file picker. Calling this method will override previous filters.

The default filter restricts selection to files only: Filters.not(Filters.eq(SearchableField.MIME_TYPE, DriveFolder.MIME_TYPE))

Note: this method cannot be used with setMimeType(String[]), doing so will throw an IllegalStateException on build(GoogleApiClient). Instead plug the desired mimeTypes into a corresponding filter.

Parameters
filter the Filter a file should match to be selectable. May not be null.