LocusIdCompat
public
final
class
LocusIdCompat
extends Object
java.lang.Object | |
↳ | 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:
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
ShortcutInfoCompat
(throughShortcutInfoCompat.Builder.setLocusId(chatId)
), if you provide a launcher shortcut for that chat conversation. - Associating it with the
ContentCaptureContext
of the root view of the chat conversation activity (throughView.getContentCaptureSession()
, thennew ContentCaptureContext.Builder(chatId).build()
andContentCaptureSession.setContentCaptureContext(android.view.contentcapture.ContentCaptureContext)
- seeContentCaptureManager
for more info about content capture). - Configuring your app to launch the chat conversation through the
Intent.ACTION_VIEW_LOCUS
intent.
Summary
Public constructors | |
---|---|
LocusIdCompat(String id)
Construct a new LocusIdCompat with the specified id. |
Public methods | |
---|---|
boolean
|
equals(Object obj)
|
String
|
getId()
Gets the canonical |
int
|
hashCode()
|
LocusId
|
toLocusId()
|
static
LocusIdCompat
|
toLocusIdCompat(LocusId locusId)
Returns an instance of LocusIdCompat from given |
String
|
toString()
|
Inherited methods | |
---|---|
Public constructors
LocusIdCompat
public LocusIdCompat (String id)
Construct a new LocusIdCompat with the specified id.
Parameters | |
---|---|
id |
String |
Throws | |
---|---|
IllegalArgumentException |
if id is empty or null .
|
Public methods
equals
public boolean equals (Object obj)
Parameters | |
---|---|
obj |
Object |
Returns | |
---|---|
boolean |
getId
public String getId ()
Gets the canonical id
associated with the locus.
Returns | |
---|---|
String |
hashCode
public int hashCode ()
Returns | |
---|---|
int |
toLocusIdCompat
public static LocusIdCompat toLocusIdCompat (LocusId locusId)
Returns an instance of LocusIdCompat from given LocusId
.
Parameters | |
---|---|
locusId |
LocusId |
Returns | |
---|---|
LocusIdCompat |
toString
public String toString ()
Returns | |
---|---|
String |