DriveEvent | Android Developers

Quicknav Quicknav
Links

- Google Play Developer Console
- Android Developers Blog
- About Android

Android Sites

- Android.com
- Android Developers
- Android Open Source Project

Language
close

- - About
  - Wear
  - TV
  - Auto
- - Get Started
  - Devices
  - Style
  - Patterns
  - Building Blocks
  - Downloads
  - Videos
- - Training
  - API Guides
  - Reference
  - Tools
  - Google Services
  - Samples
- - Google Play
  - Essentials
  - Get Users
  - Engage & Retain
  - Monetize
  - Tools & Reference
  - Developer Stories

## Results

Loading...
Summary: Nested Classes | Constants | Inherited Constants | Methods | Inherited Methods | [Expand All]
public interface

# DriveEvent

implements SafeParcelable

com.google.android.gms.drive.events.DriveEvent

Known Indirect Subclasses ChangeEvent, ResourceEvent
ChangeEvent | Sent when a `DriveResource` has had a change to its `Contents` or `Metadata`.
ResourceEvent | Base interface for `DriveEvent` types related to a specific resource.

## Class Overview

Base interface implemented by all Drive event types. An application can express interest in receiving events by adding an event listener or subscription.

An event listener implements the `DriveEvent.Listener` interface for a particular event type and receives a direct callback from the Drive service to a client application that is currently connected. A listener is added by calling the appropriate `addListener` method on the `DriveResource` of interest or on `DriveApi` for listeners that are not resource-specific. Listeners are active for the duration of the current connection or until the `removeListener` method is called on the same entity with the same callback parameter.

An event subscription is used to indicate that an application is interested in receiving events via intents, even if the application is not currently connected or even running. A subscription is added by calling the appropriate `addSubscription` method on the `DriveResource` of interest or on `DriveApi` for subscriptions that are not resource-specific, passing the class name of an exported `DriveEventService` subclass that will process the event intents delivered as a result of the subscription. Subscriptions are active until the `removeSubscription` method is called on the same entity with the same service class or until the next device reboot. An application that is interested in maintaining any subscriptions across reboots should handle the `ACTION_BOOT_COMPLETED` intent to add back these subscriptions after the reboot has completed.

A client can have both listeners and subscriptions active for a given resource at the same time. When an event is raised, the Drive service will have a preference for delivering events to listeners over subscriptions. If an event is delivered to successfully to one or more listeners for a connected client, then the event will not be delivered to any active subscriptions for the same client application. An event can be delivered to multiple listeners or multiple subscribers for a given application but never to both.

## Summary

Nested Classes
interface | DriveEvent.Listener<E extends DriveEvent> | Listens for Drive events of a particular type.

Constants
int | TYPE_CHANGE | Event type that indicates a resource change.

[Expand] Inherited Constants
From interface android.os.Parcelable
int | CONTENTS_FILE_DESCRIPTOR |
int | PARCELABLE_WRITE_RETURN_VALUE |
From interface com.google.android.gms.common.internal.safeparcel.SafeParcelable
String | NULL |

Public Methods
abstract DriveId | getDriveId() Returns the id of the Drive resource that triggered the event, or `null` if not resource-specific.
abstract int | getType() Returns the type of an event.

[Expand] Inherited Methods
From interface android.os.Parcelable
abstract int | describeContents()
abstract void | writeToParcel(Parcel arg0, int arg1)

## Constants

#### public static final int TYPE_CHANGE

Event type that indicates a resource change.

##### See Also

- `ChangeEvent`

Constant Value: 1 (0x00000001)

## Public Methods

#### public abstract DriveId getDriveId ()

Returns the id of the Drive resource that triggered the event, or `null` if not resource-specific.

#### public abstract int getType ()

Returns the type of an event. See the `TYPE_*` constants for possible values.