minor edits
This commit is contained in:
Родитель
8e4c8abc15
Коммит
d8d36b565a
|
@ -33,7 +33,7 @@ appServiceClientConnection.addListener(listener);
|
||||||
appServiceClientConnection.openRemoteAsync();
|
appServiceClientConnection.openRemoteAsync();
|
||||||
|
|
||||||
```
|
```
|
||||||
## Communicate with the app service
|
## Send and receive messages
|
||||||
A listener object is needed to handle all communication with the remote app service. Create a class that implements **IAppServiceClientConnectionListener** to serve this purpose.
|
A listener object is needed to handle all communication with the remote app service. Create a class that implements **IAppServiceClientConnectionListener** to serve this purpose.
|
||||||
|
|
||||||
```java
|
```java
|
||||||
|
@ -41,10 +41,10 @@ A listener object is needed to handle all communication with the remote app serv
|
||||||
class AppConnectionListener implements IAppServiceClientConnectionListener {
|
class AppConnectionListener implements IAppServiceClientConnectionListener {
|
||||||
|
|
||||||
public void openRemoteSuccess(AppServiceClientConnectionStatus status) {
|
public void openRemoteSuccess(AppServiceClientConnectionStatus status) {
|
||||||
if (status == SUCCESS) {
|
if (status == SUCCESS???) {
|
||||||
|
// create and send a message to the app service
|
||||||
Bundle message = new Bundle();
|
Bundle message = new Bundle();
|
||||||
message.putChar("here is my message", 'a');
|
message.putChar("here is my message", 'a');
|
||||||
//send the message
|
|
||||||
appServiceClientConnection.sendMessageAsync(message);
|
appServiceClientConnection.sendMessageAsync(message);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -52,21 +52,21 @@ class AppConnectionListener implements IAppServiceClientConnectionListener {
|
||||||
public void responseReceived(AppServiceClientResponse response) {
|
public void responseReceived(AppServiceClientResponse response) {
|
||||||
|
|
||||||
//check that the message was successfully transmitted
|
//check that the message was successfully transmitted
|
||||||
if (response.getStatus() == SUCCESS) {
|
if (response.getStatus() == SUCCESS) {
|
||||||
//it worked, lets send another message
|
// send another message to the app service, or receive???
|
||||||
Bundle message = new Bundle();
|
Bundle message = new Bundle();
|
||||||
message.putChar("another message",'b');
|
message.putChar("another message",'b');
|
||||||
appServiceClientConnection.sendMessageAsync(message);
|
appServiceClientConnection.sendMessageAsync(message);
|
||||||
} else {
|
} else {
|
||||||
log("The message was " + response.getStatus().toString());
|
log("The message status was " + response.getStatus().toString());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
When your app is finished messaging/querying the host device's app service, close the connection between the two devices.
|
When your app is finished interacting with the host device's app service, close the connection between the two devices.
|
||||||
|
|
||||||
```java
|
```java
|
||||||
// Close AppConnection
|
// Close connection
|
||||||
appServiceClientConnection.close();
|
appServiceClientConnection.close();
|
||||||
```
|
```
|
Загрузка…
Ссылка в новой задаче