TrustedWebActivityServiceConnection
public
final
class
TrustedWebActivityServiceConnection
extends Object
java.lang.Object
|
↳ |
androidx.browser.trusted.TrustedWebActivityServiceConnection
|
TrustedWebActivityServiceConnection is used by a Trusted Web Activity provider to wrap calls to
the TrustedWebActivityService
in the client app.
All of these calls except getComponentName()
forward over IPC
to corresponding calls on TrustedWebActivityService
, eg getSmallIconId()
forwards to TrustedWebActivityService.onGetSmallIconId()
.
These IPC calls are synchronous, though the TrustedWebActivityService
method may hit the
disk. Therefore it is recommended to call them on a background thread (without StrictMode).
Summary
Inherited methods |
From class
java.lang.Object
Object
|
clone()
|
boolean
|
equals(Object arg0)
|
void
|
finalize()
|
final
Class<?>
|
getClass()
|
int
|
hashCode()
|
final
void
|
notify()
|
final
void
|
notifyAll()
|
String
|
toString()
|
final
void
|
wait(long arg0, int arg1)
|
final
void
|
wait(long arg0)
|
final
void
|
wait()
|
|
Public methods
areNotificationsEnabled
public boolean areNotificationsEnabled (String channelName)
Checks whether notifications are enabled.
Parameters |
channelName |
String : The name of the channel to check enabled status. Only used on Android O+. |
Returns |
boolean |
Whether notifications or the notification channel is blocked for the client app. |
Throws |
RemoteException |
If the Service dies while responding to the request. |
SecurityException |
If verification with the TrustedWebActivityService fails.
|
cancel
public void cancel (String platformTag,
int platformId)
Requests a notification be cancelled.
Parameters |
platformTag |
String : The tag to identify the notification. |
platformId |
int : The id to identify the notification. |
Throws |
RemoteException |
If the Service dies while responding to the request. |
SecurityException |
If verification with the TrustedWebActivityService fails.
|
getComponentName
public ComponentName getComponentName ()
Gets the ComponentName
of the connected Trusted Web Activity client app.
Returns |
ComponentName |
The Trusted Web Activity client app component name.
|
getSmallIconBitmap
public Bitmap getSmallIconBitmap ()
Requests a bitmap of a small icon to be used for the notification
small icon. The bitmap is decoded on the side of Trusted Web Activity client using
the resource id from TrustedWebActivityService.onGetSmallIconId()
.
Throws |
RemoteException |
If the Service dies while responding to the request. |
SecurityException |
If verification with the TrustedWebActivityService fails.
|
getSmallIconId
public int getSmallIconId ()
Requests an Android resource id to be used for the notification small icon.
Returns |
int |
An Android resource id for the notification small icon. -1 if non found. |
Throws |
RemoteException |
If the Service dies while responding to the request. |
SecurityException |
If verification with the TrustedWebActivityService fails.
|
notify
public boolean notify (String platformTag,
int platformId,
Notification notification,
String channel)
Requests a notification be shown.
Parameters |
platformTag |
String : The tag to identify the notification. |
platformId |
int : The id to identify the notification. |
notification |
Notification : The notification. |
channel |
String : The name of the channel in the Trusted Web Activity client app to display the
notification on. |
Returns |
boolean |
Whether notifications or the notification channel are blocked for the client app. |
Throws |
RemoteException |
If the Service dies while responding to the request. |
SecurityException |
If verification with the TrustedWebActivityService fails.
|
sendExtraCommand
public Bundle sendExtraCommand (String commandName,
Bundle args,
TrustedWebActivityCallback callback)
Passes a free-form command to the client.
TrustedWebActivityService.onExtraCommand(String, Bundle, TrustedWebActivityCallbackRemote)
will be called.
The client may not know how to deal with the command, in which case null
may be
returned.
Parameters |
commandName |
String : Name of the command to execute. |
args |
Bundle : Arguments to the command. |
callback |
TrustedWebActivityCallback : Callback that may be used to return data, depending on the command. |
Returns |
Bundle |
The result Bundle , or null if the command could not be executed. |
Throws |
RemoteException |
If the Service dies while responding to the request. |
SecurityException |
If verification with the TrustedWebActivityService fails.
|