LocusIdCompat
class 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 intelligence service provided by 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:
LocusIdCompat chatId = new LocusIdCompat("Chat_A_B");
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.ContentCaptureContextof the root view of the chat conversation activity (throughgetContentCaptureSession, thennew ContentCaptureContext.Builder(chatId).build()andsetContentCaptureContext- seeandroid.view.contentcapture.ContentCaptureManagerfor more info about content capture). - Configuring your app to launch the chat conversation through the
ACTION_VIEW_LOCUSintent.
android.view.contentcapture.ContentCaptureManager for more details.
Summary
Public constructors |
|---|
LocusIdCompat(id: String)Construct a new LocusIdCompat with the specified id. |
Public functions |
|
|---|---|
Boolean |
|
String |
getId()Gets the canonical |
Int |
hashCode() |
LocusId |
@RequiresApi(value = 29) |
java-static LocusIdCompat |
@RequiresApi(value = 29)Returns an instance of LocusIdCompat from given |
String |
toString() |
Public constructors
LocusIdCompat
LocusIdCompat(id: String)
Construct a new LocusIdCompat with the specified id.
| Throws | |
|---|---|
java.lang.IllegalArgumentException |
if |
Public functions
toLocusIdCompat
@RequiresApi(value = 29)
java-static fun toLocusIdCompat(locusId: LocusId): LocusIdCompat
Returns an instance of LocusIdCompat from given LocusId.