This class manages a connection to an app service on a remote device.
public final class AppServiceConnection
Initializes an instance of the AppServiceConnection class with a name and Id of the app service, a generic remote connection request, and a listeners for related connection events.
public AppServiceConnection(String appServiceName, String appIdentifier, RemoteSystemConnectionRequest request, IAppServiceConnectionListener appServiceConnectionListener, IAppServiceRequestListener requestListener) throws InvalidParameterException
appServiceName - the name of the remote app service. See Create and consume an app service for details.
appIdentifier - the package family name of the remote app service. See See Create and consume an app service for details.
request - a RemoteSystemConnectionRequest object representing the intent to connect to a specific remote system
appServiceConnectionListener - an IAppServiceConnectionListener that handles events related to the connection itself.
requestListener - an IAppServiceRequestListener that handles incoming app service requests over the remote app service connection.
Opens a connection to the remote app service specified in this class' constructor. If the connection fails to open, an exception is thrown.
public void openRemoteAsync() throws ConnectedDevicesException
Sends a message to the connected remote app service consisting of key/value pairs.
public void sendMessageAsync(Bundle messageBundle, IAppServiceResponseListener responseListener) throws ConnectedDevicesException
messageBundle - a Bundle object containing String keys mapped to values of variable types
responseListener - an IAppServiceResponseListener that handles the receipt of the remote app service's response to the message being sent.
Closes the connection to the remote app service. This is recommended when the client app closes or stops.
public void closeAsync()
Returns the app service name with which this AppServiceConnection instance was constructed.
public String getAppServiceName()
The name string of the target app service.
Returns the package family name with which this AppServiceConnection instance was constructed.
public String getPackageFamilyName()
The package family name string of the target app service.