次の方法で共有


Intent.ActionOpenDocument Field

Definition

Activity Action: Allow the user to select and return one or more existing documents.

[Android.Runtime.Register("ACTION_OPEN_DOCUMENT")]
public const string ActionOpenDocument;
[<Android.Runtime.Register("ACTION_OPEN_DOCUMENT")>]
val mutable ActionOpenDocument : string

Field Value

Implements

Attributes

Remarks

Activity Action: Allow the user to select and return one or more existing documents. When invoked, the system will display the various DocumentsProvider instances installed on the device, letting the user interactively navigate through them. These documents include local media, such as photos and video, and documents provided by installed cloud storage providers.

Each document is represented as a content:// URI backed by a DocumentsProvider, which can be opened as a stream with ContentResolver#openFileDescriptor(Uri, String), or queried for android.provider.DocumentsContract.Document metadata.

All selected documents are returned to the calling application with persistable read and write permission grants. If you want to maintain access to the documents across device reboots, you need to explicitly take the persistable permissions using ContentResolver#takePersistableUriPermission(Uri, int).

Callers must indicate the acceptable document MIME types through #setType(String). For example, to select photos, use image/*. If multiple disjoint MIME types are acceptable, define them in #EXTRA_MIME_TYPES and #setType(String) to */*.

If the caller can handle multiple returned items (the user performing multiple selection), then you can specify #EXTRA_ALLOW_MULTIPLE to indicate this.

Callers must include #CATEGORY_OPENABLE in the Intent to obtain URIs that can be opened with ContentResolver#openFileDescriptor(Uri, String).

Callers can set a document URI through DocumentsContract#EXTRA_INITIAL_URI to indicate the initial location of documents navigator. System will do its best to launch the navigator in the specified document if it's a folder, or the folder that contains the specified document if not.

Output: The URI of the item that was picked, returned in #getData(). This must be a content:// URI so that any receiver can access it. If multiple documents were selected, they are returned in #getClipData().

Java documentation for android.content.Intent.ACTION_OPEN_DOCUMENT.

Portions of this page are modifications based on work created and shared by the Android Open Source Project and used according to terms described in the Creative Commons 2.5 Attribution License.

Applies to

See also