public final class DragAndDropPermissions extends Object implements Parcelable
DragAndDropPermissions
controls the access permissions for the content URIs associated
with a DragEvent
.
Permission are granted when this object is created by Activity.requestDragAndDropPermissions
.
Which permissions are granted is defined by the set of flags passed to View.startDragAndDrop
by the app that started the drag operation.
The life cycle of the permissions is bound to the activity used to call requestDragAndDropPermissions
. The
permissions are revoked when this activity is destroyed, or when release()
is called,
whichever occurs first.
If you anticipate that your application will receive a large number of drops (e.g. document
editor), you should try to call release()
on the obtained permissions as soon as they
are no longer required. Permissions can be added to your activity's
Activity.onSaveInstanceState(android.os.Bundle)
bundle and later retrieved in order to manually release
the permissions once they are no longer needed.
Parcelable.ClassLoaderCreator<T>, Parcelable.Creator<T>
Modifier and Type | Field and Description |
---|---|
static Parcelable.Creator<DragAndDropPermissions> |
CREATOR |
CONTENTS_FILE_DESCRIPTOR, PARCELABLE_ELIDE_DUPLICATES, PARCELABLE_WRITE_RETURN_VALUE
Modifier and Type | Method and Description |
---|---|
int |
describeContents()
Describe the kinds of special objects contained in this Parcelable
instance's marshaled representation.
|
static DragAndDropPermissions |
obtain(DragEvent dragEvent)
Create a new
DragAndDropPermissions object to control the access permissions for
content URIs associated with DragEvent . |
void |
release()
Revoke permissions explicitly.
|
boolean |
take(IBinder activityToken)
Take the permissions and bind their lifetime to the activity.
|
boolean |
takeTransient()
Take the permissions.
|
void |
writeToParcel(Parcel destination,
int flags)
Flatten this object in to a Parcel.
|
public static final Parcelable.Creator<DragAndDropPermissions> CREATOR
public static DragAndDropPermissions obtain(DragEvent dragEvent)
DragAndDropPermissions
object to control the access permissions for
content URIs associated with DragEvent
.dragEvent
- Drag eventDragAndDropPermissions
object or null if there are no content URIs associated
with the DragEvent
.public boolean take(IBinder activityToken)
activityToken
- Binder pointing to an Activity instance to bind the lifetime to.public boolean takeTransient()
release()
explicitly.public void release()
public int describeContents()
Parcelable
Parcelable.writeToParcel(Parcel, int)
,
the return value of this method must include the
Parcelable.CONTENTS_FILE_DESCRIPTOR
bit.describeContents
in interface Parcelable
Parcelable.CONTENTS_FILE_DESCRIPTOR
public void writeToParcel(Parcel destination, int flags)
Parcelable
writeToParcel
in interface Parcelable
destination
- The Parcel in which the object should be written.flags
- Additional flags about how the object should be written.
May be 0 or Parcelable.PARCELABLE_WRITE_RETURN_VALUE
.