RemoteInteractionsManager
public
final
class
RemoteInteractionsManager
extends Object
| java.lang.Object | |
| ↳ | com.google.wear.services.remoteinteractions.RemoteInteractionsManager |
The API for managing remote interactions.
Remote Interactions are operations issued by the watch to a companion device, such as paired phone. They are not available when there is no paired device present.
An instance of this class can be obtained directly via the Wear OS SDK by invoking the following API:
com.google.wear.Sdk.getWearManager(context, RemoteInteractionsManager.class);
Summary
Constants | |
|---|---|
int |
STATUS_AVAILABLE
Indicates that remote interaction is available. |
int |
STATUS_TEMPORARILY_UNAVAILABLE
Indicates that remote interaction is temporarily unavailable. |
int |
STATUS_UNAVAILABLE
Indicates that remote interaction is unavailable. |
int |
STATUS_UNKNOWN
The remote interaction's availability is unknown. |
Public methods | |
|---|---|
void
|
continueActivityOnPhoneWithUnlock(String targetPackage, String targetAction, Uri targetUri, List<String> targetCategories, String callerPackage, Executor executor, OutcomeReceiver<Void, Throwable> outcomeReceiver)
Start a Remote Activity on the connected companion phone after unlocking the phone. |
void
|
registerContinueActivityOnPhoneWithUnlockStatusListener(Executor listenerExecutor, Consumer<Integer> listener)
Registers a listener for ContinueActivityOnPhoneWithUnlock's availability status changes. |
void
|
registerRemoteActivityHelperStatusListener(Executor listenerExecutor, Consumer<Integer> listener)
Registers a listener for RemoteActivityHelper's availability status change. |
void
|
registerRemoteAuthClientStatusListener(Executor listenerExecutor, Consumer<Integer> listener)
Registers a listener for RemoteAuthClient's availability status change. |
void
|
startRemoteActivity(Uri dataUri, List<String> additionalCategories, Executor executor, OutcomeReceiver<Void, Throwable> outcomeReceiver)
Starts a Remote Activity on the connected Companion device where the intent action will be
set to |
void
|
unregisterContinueActivityOnPhoneWithUnlockStatusListener(Consumer<Integer> listener)
Unregisters a listener for ContinueActivityOnPhoneWithUnlock's availability status changes. |
void
|
unregisterRemoteActivityHelperStatusListener(Consumer<Integer> listener)
Unregisters a listener for RemoteActivityHelper's availability status change. |
void
|
unregisterRemoteAuthClientStatusListener(Consumer<Integer> listener)
Unregisters a listener for RemoteAuthClient's availability status change. |
Inherited methods | |
|---|---|
Constants
STATUS_AVAILABLE
public static final int STATUS_AVAILABLE
Indicates that remote interaction is available.
This indicates that there is a connected device capable to handle the remote interaction.
Constant Value: 3 (0x00000003)
STATUS_TEMPORARILY_UNAVAILABLE
public static final int STATUS_TEMPORARILY_UNAVAILABLE
Indicates that remote interaction is temporarily unavailable.
This indicates that there is a known device capable of handling remote interactions, but that it is not currently connected.
Constant Value: 2 (0x00000002)
STATUS_UNAVAILABLE
public static final int STATUS_UNAVAILABLE
Indicates that remote interaction is unavailable.
This indicates that there is no paired device capable to handle the remote interaction.
Constant Value: 1 (0x00000001)
STATUS_UNKNOWN
public static final int STATUS_UNKNOWN
The remote interaction's availability is unknown.
Constant Value: 0 (0x00000000)
Public methods
continueActivityOnPhoneWithUnlock
public void continueActivityOnPhoneWithUnlock (String targetPackage,
String targetAction,
Uri targetUri,
List<String> targetCategories,
String callerPackage,
Executor executor,
OutcomeReceiver<Void, Throwable> outcomeReceiver)Start a Remote Activity on the connected companion phone after unlocking the phone.
This API determines if the request qualifies to unlock the phone and start an activity on
it. Qualification is that the caller should be in the foreground, have permission granted.
Target intent should be within the same package on the phone, or the target intent is an
Intent.ACTION_VIEW action with category Intent.CATEGORY_BROWSABLE with an empty package and the URI starting with "https". If the request qualifies, it sends the request to
Companion. Otherwise, the request will be rejected and the result will be returned via OutcomeReceiver. If unlock is not successful, the request will fail and the result will be
returned via OutcomeReceiver as well.
Based on the parameters provided, the intent that will be sent to the phone will be constructed as follows:
Intent remoteIntent = new Intent()
.setPackage(targetPackage)
.setAction(targetAction)
.setData(targetUri);
for (String category : targetCategories) {
remoteIntent.addCategory(category);
}
Requires com.google.wear.services.Permissions.SEND_CONTINUE_ACTIVITY_ON_PHONE
| Parameters | |
|---|---|
targetPackage |
String: The package name of the intent to open on the remote device. |
targetAction |
String: The action of the intent to open on the remote device. |
targetUri |
Uri: The data Uri of the intent to open on the remote device. |
targetCategories |
List: The categories of the intent to open on the remote device. |
callerPackage |
String: Caller specifies their package name. Needed to address cases of shared
UID. |
executor |
Executor: The executor to use for the callback |
outcomeReceiver |
OutcomeReceiver: An OutcomeReceiver to pass the operation result back to the
caller as described above. |
registerContinueActivityOnPhoneWithUnlockStatusListener
public void registerContinueActivityOnPhoneWithUnlockStatusListener (Executor listenerExecutor,
Consumer<Integer> listener)Registers a listener for ContinueActivityOnPhoneWithUnlock's availability status changes. ContinueActivityOnPhoneWithUnlock can then be used to unlock the phone and launch an activity on the paired phone.
Initial availability status will be delivered upon registration once known.
Requires com.google.wear.services.Permissions.SEND_CONTINUE_ACTIVITY_ON_PHONE
| Parameters | |
|---|---|
listenerExecutor |
Executor: The executor that the listener runs on. This value cannot be null. Listener events are dispatched through this Executor, providing an easy way to
control which thread is used. To dispatch events through the main thread of your
application, you can use Context.getMainExecutor(). |
listener |
Consumer: A listener that will consume the availability status change, see AvailabilityStatus.
Value is one of the following: |
registerRemoteActivityHelperStatusListener
public void registerRemoteActivityHelperStatusListener (Executor listenerExecutor,
Consumer<Integer> listener)Registers a listener for RemoteActivityHelper's availability status change. RemoteActivityHelper can be used to open a screen on the phone.
Initial availability status will be delivered upon registration once known.
| Parameters | |
|---|---|
listenerExecutor |
Executor: The executor that the listener runs on. This value cannot be null. Listener events are dispatched through this Executor, providing an easy way to
control which thread is used. To dispatch events through the main thread of your
application, you can use Context.getMainExecutor(). |
listener |
Consumer: A listener that will consume the availability status change, see AvailabilityStatus.
Value is one of the following: |
registerRemoteAuthClientStatusListener
public void registerRemoteAuthClientStatusListener (Executor listenerExecutor,
Consumer<Integer> listener)Registers a listener for RemoteAuthClient's availability status change. RemoteAuthClient can be used to initiate remote authentication on the phone.
Initial availability status will be delivered upon registration once known.
| Parameters | |
|---|---|
listenerExecutor |
Executor: The executor that the listener runs on. This value cannot be null. Listener events are dispatched through this Executor, providing an easy way to
control which thread is used. To dispatch events through the main thread of your
application, you can use Context.getMainExecutor(). |
listener |
Consumer: A listener that will consume the availability status change, see AvailabilityStatus.
Value is one of the following: |
startRemoteActivity
public void startRemoteActivity (Uri dataUri,
List<String> additionalCategories,
Executor executor,
OutcomeReceiver<Void, Throwable> outcomeReceiver)Starts a Remote Activity on the connected Companion device where the intent action will be
set to Intent.ACTION_VIEW.
This API must be called from the foreground. Otherwise, the request will be rejected and
an error will be returned via the OutcomeReceiver.
How the intent will be constructed:
Intent remoteIntent = new Intent(Intent.ACTION_VIEW)
.setData(dataUri)
.addCategory(Intent.CATEGORY_BROWSABLE);
if (additionalCategories != null) {
for (String category : additionalCategories) {
remoteIntent.addCategory(category);
}
}
| Parameters | |
|---|---|
dataUri |
Uri: for the intent to open on the remote device, this data uri will be populated
using Intent.setData. |
additionalCategories |
List: the categories to use, the category Intent.CATEGORY_BROWSABLE will be added to the list of categories. |
executor |
Executor: the executor which will be used to make the call and process the result. |
outcomeReceiver |
OutcomeReceiver: an OutcomeReceiver that will receive a void result when the
activity was started successfully. |
unregisterContinueActivityOnPhoneWithUnlockStatusListener
public void unregisterContinueActivityOnPhoneWithUnlockStatusListener (Consumer<Integer> listener)
Unregisters a listener for ContinueActivityOnPhoneWithUnlock's availability status changes.
Requires com.google.wear.services.Permissions.SEND_CONTINUE_ACTIVITY_ON_PHONE
| Parameters | |
|---|---|
listener |
Consumer: A previously registered listener from registerContinueActivityOnPhoneWithUnlockStatusListener.
Value is one of the following: |
| Throws | |
|---|---|
IllegalArgumentException |
if the listener is not registered. |
unregisterRemoteActivityHelperStatusListener
public void unregisterRemoteActivityHelperStatusListener (Consumer<Integer> listener)
Unregisters a listener for RemoteActivityHelper's availability status change.
| Parameters | |
|---|---|
listener |
Consumer: A previously registered listener from registerRemoteActivityHelperStatusListener.
Value is one of the following: |
| Throws | |
|---|---|
IllegalArgumentException |
if the listener is not registered. |
unregisterRemoteAuthClientStatusListener
public void unregisterRemoteAuthClientStatusListener (Consumer<Integer> listener)
Unregisters a listener for RemoteAuthClient's availability status change.
| Parameters | |
|---|---|
listener |
Consumer: A previously registered listener from registerRemoteAuthClientStatusListener.
Value is one of the following: |
| Throws | |
|---|---|
IllegalArgumentException |
if the listener is not registered. |