LocusIdCompat
class LocusIdCompat
kotlin.Any | |
↳ | androidx.core.content.LocusIdCompat |
An identifier for an unique state (locus) in the application. Should be stable across reboots and backup / restore.
Locus is a new concept introduced on Android Q
and it lets the Android system correlate state between different subsystems such as content capture, shortcuts, and notifications.
For example, if your app provides an activity representing a chat between 2 users (say A
and B
, this chat state could be represented by:
<code> LocusIdCompat chatId = new LocusIdCompat("Chat_A_B"); </code>
And then you should use that chatId
by:
- Setting it in the chat notification (through
NotificationCompat.Builder.setLocusId(chatId)
). - Setting it into the
androidx.core.content.pm.ShortcutInfoCompat
(throughShortcutInfoCompat.Builder.setLocusId(chatId)
), if you provide a launcher shortcut for that chat conversation. - Associating it with the
android.view.contentcapture.ContentCaptureContext
of the root view of the chat conversation activity (throughandroid.view.View#getContentCaptureSession()
, thennew ContentCaptureContext.Builder(chatId).build()
andandroid.view.contentcapture.ContentCaptureSession#setContentCaptureContext( * android.view.contentcapture.ContentCaptureContext)
- seeandroid.view.contentcapture.ContentCaptureManager
for more info about content capture). - Configuring your app to launch the chat conversation through the
Intent#ACTION_VIEW_LOCUS
intent.
Summary
Public constructors | |
---|---|
Construct a new LocusIdCompat with the specified id. |
Public methods | |
---|---|
Boolean | |
String |
getId() Gets the canonical |
Int |
hashCode() |
LocusId | |
static LocusIdCompat |
toLocusIdCompat(@NonNull locusId: LocusId) Returns an instance of LocusIdCompat from given |
String |
toString() |
Public constructors
<init>
LocusIdCompat(@NonNull id: String)
Construct a new LocusIdCompat with the specified id.
Exceptions | |
---|---|
IllegalArgumentException |
if id is empty or null . |
Public methods
hashCode
fun hashCode(): Int
toLocusId
@NonNull @RequiresApi(29) fun toLocusId(): LocusId
Return | |
---|---|
LocusId |
LocusId object from this compat object. |
toLocusIdCompat
@NonNull @RequiresApi(29) static fun toLocusIdCompat(@NonNull locusId: LocusId): LocusIdCompat
Returns an instance of LocusIdCompat from given LocusId
.
toString
@NonNull fun toString(): String