Notification.MessagingStyle.Message.SetData(String, Uri) Method
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Sets a binary blob of data and an associated MIME type for a message.
[Android.Runtime.Register("setData", "(Ljava/lang/String;Landroid/net/Uri;)Landroid/app/Notification$MessagingStyle$Message;", "", ApiSince=24)]
public Android.App.Notification.MessagingStyle.Message SetData(string dataMimeType, Android.Net.Uri dataUri);
[<Android.Runtime.Register("setData", "(Ljava/lang/String;Landroid/net/Uri;)Landroid/app/Notification$MessagingStyle$Message;", "", ApiSince=24)>]
member this.SetData : string * Android.Net.Uri -> Android.App.Notification.MessagingStyle.Message
Parameters
- dataMimeType
- String
String: The MIME type of the content. See android.graphics.ImageDecoder.isMimeTypeSupported(String) for a list of supported image MIME types.
- dataUri
- Uri
Uri: The uri containing the content whose type is given by the MIME type. Notification Listeners including the System UI need permission to access the data the Uri points to. The recommended ways to do this are: Store the data in your own ContentProvider, making sure that other apps have the correct permission to access your provider. The preferred mechanism for providing access is to use per-URI permissions which are temporary and only grant access to the receiving application. An easy way to create a ContentProvider like this is to use the FileProvider helper class. Use the system MediaStore. The MediaStore is primarily aimed at video, audio and image MIME types, however beginning with Android 3.0 (API level 11) it can also store non-media types (see MediaStore.Files for more info). Files can be inserted into the MediaStore using scanFile() after which a content:// style Uri suitable for sharing is passed to the provided onScanCompleted() callback. Note that once added to the system MediaStore the content is accessible to any app on the device.
Returns
this object for method chaining
- Attributes
Remarks
Sets a binary blob of data and an associated MIME type for a message. In the case where the platform or the UI state doesn't support the MIME type, the original text provided in the constructor will be used. When this data can be presented to the user, the original text will only be used as accessibility text.
Content and code samples on this page are subject to the licenses described in the Content License. Java and OpenJDK are trademarks or registered trademarks of Oracle and/or its affiliates.
Last updated 2026-08-03 UTC.
Android reference for android.app.Notification.MessagingStyle.Message.setData.
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.