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

CreateFileActivityBuilder

public class CreateFileActivityBuilder extends Object

This class was deprecated.
Use CreateFileActivityOptions instead.

A builder that is used to configure and display the create file activity. This dialog creates a new file in the user's drive with a destination and file title selected by the user. If the device is currently offline, the file will be created locally and committed to the server when connectivity is restored.

To create a new DriveFile, the following objects should be provided through the setters in this class before build(GoogleApiClient) is called:

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 that specifies the DriveId for the newly created file.

Note: you cannot use #startIntentSender 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 created file.

Public Method Summary

IntentSender
build(GoogleApiClient apiClient)
Gets an Intent that can be used to start the Create File activity.
CreateFileActivityBuilder
setActivityStartFolder(DriveId folder)
Sets the default folder that will be presented at activity startup as the location for file creation.
CreateFileActivityBuilder
setActivityTitle(String title)
Sets the title displayed in the activity.
CreateFileActivityBuilder
setInitialDriveContents(DriveContents driveContents)
Sets the initial DriveContents for the new file.
CreateFileActivityBuilder
setInitialMetadata(MetadataChangeSet metadataChangeSet)
Sets the initial metadata for the new file.

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 created file.

Constant Value: "response_drive_id"

Public Methods

public IntentSender build (GoogleApiClient apiClient)

Gets an Intent that can be used to start the Create File activity. Note that you must start this activity with startIntentSenderForResult, not startIntentSender. Once this is invoked, the provided contents are finalized and cannot be edited. To make additional edits, reopen the contents with the returned DriveId.

This method requires authorization with at least one of the following scopes: SCOPE_FILE. Otherwise, a RuntimeException will be thrown.

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

public CreateFileActivityBuilder setActivityStartFolder (DriveId folder)

Sets the default folder that will be presented at activity startup as the location for file creation. The activity supports navigation from this point to other folders. If not set, defaults to the root folder in the user's Drive.

If this method is called multiple times before build(GoogleApiClient), the last call will overwrite any previous value.

public CreateFileActivityBuilder setActivityTitle (String title)

Sets the title displayed in the activity.

If this method is called multiple times before build(GoogleApiClient), the last call will overwrite any previous value.

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

public CreateFileActivityBuilder setInitialDriveContents (DriveContents driveContents)

Sets the initial DriveContents for the new file. This will persist the contents as the initial contents for the file. To continue editing the contents, open them again through open(GoogleApiClient, int, DriveFile.DownloadProgressListener) once the file has been created.

This method must always be called or the build(GoogleApiClient) method will fail. If this method is called multiple times before build(GoogleApiClient), the last call will overwrite any previous value.

Parameters
driveContents The initial contents. The provided contents must have been obtained through newDriveContents(GoogleApiClient). This DriveContents cannot be reused after this method returns. This parameter may also be set to null to create an empty file, but it is recommended to create non-empty files where the mime-type does not support having a zero byte file (for example, image or PDF files).

public CreateFileActivityBuilder setInitialMetadata (MetadataChangeSet metadataChangeSet)

Sets the initial metadata for the new file.

This method must be called or the build(GoogleApiClient) method will fail. A new MetadataChangeSet can be created using MetadataChangeSet.Builder. If this method is called multiple times before build(GoogleApiClient), the last call will overwrite any previous value.