Freigeben über


MediaStore.CreateFavoriteRequest Method

Definition

Create a PendingIntent that will prompt the user to favorite the requested media items.

[Android.Runtime.Register("createFavoriteRequest", "(Landroid/content/ContentResolver;Ljava/util/Collection;Z)Landroid/app/PendingIntent;", "", ApiSince=30)]
public static Android.App.PendingIntent CreateFavoriteRequest (Android.Content.ContentResolver resolver, System.Collections.Generic.ICollection<Android.Net.Uri> uris, bool value);
[<Android.Runtime.Register("createFavoriteRequest", "(Landroid/content/ContentResolver;Ljava/util/Collection;Z)Landroid/app/PendingIntent;", "", ApiSince=30)>]
static member CreateFavoriteRequest : Android.Content.ContentResolver * System.Collections.Generic.ICollection<Android.Net.Uri> * bool -> Android.App.PendingIntent

Parameters

resolver
ContentResolver

Used to connect with MediaStore#AUTHORITY. Typically this value is Context#getContentResolver(), but if you need more explicit lifecycle controls, you can obtain a ContentProviderClient and wrap it using ContentResolver#wrap(ContentProviderClient).

uris
ICollection<Uri>

The set of media items to include in this request. Each item must be hosted by MediaStore#AUTHORITY and must reference a specific media item by BaseColumns#_ID.

value
Boolean

The MediaColumns#IS_FAVORITE value to apply.

Returns

Attributes

Remarks

Create a PendingIntent that will prompt the user to favorite the requested media items. When the user approves this request, MediaColumns#IS_FAVORITE is set on these items.

This call only generates the request for a prompt; to display the prompt, call Activity#startIntentSenderForResult with PendingIntent#getIntentSender(). You can then determine if the user granted your request by testing for Activity#RESULT_OK in Activity#onActivityResult. The requested operation will have completely finished before this activity result is delivered.

The displayed prompt will reflect all the media items you're requesting, including those for which you already hold write access. If you want to determine if you already hold write access before requesting access, use Context#checkUriPermission(Uri, int, int, int) with Intent#FLAG_GRANT_WRITE_URI_PERMISSION.

Java documentation for android.provider.MediaStore.createFavoriteRequest(android.content.ContentResolver, java.util.Collection<android.net.Uri>, boolean).

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