Skip to content

Commit d396477

Browse files
author
Paul Ruiz
committed
Added Wear Messaging API demo
1 parent 7a2f1a0 commit d396477

File tree

3 files changed

+16
-2
lines changed

3 files changed

+16
-2
lines changed

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,8 @@ Wear: Examples of possible notifications using the Google Wear developer preview
4949

5050
WearCustomWatchFace: Creates a custom watch face for the Android Wear with a settings activity. Uses an undocumented API, but I'll have a sample up when an official API is available.
5151

52+
WearMessageApi: Demonstration of communication between a smartphone and Android Wear device through the Wearable Message API. Article describing the demo can be found at www.binpress.com/tutorials
53+
5254
------------------------------------------------------------------------------------------------
5355

5456
License

WearMessageApi/mobile/src/main/java/com/ptrprograms/wearmessageapi/MainActivity.java

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
import com.google.android.gms.wearable.Wearable;
1717

1818

19-
public class MainActivity extends Activity {
19+
public class MainActivity extends Activity implements GoogleApiClient.ConnectionCallbacks {
2020

2121
private static final String START_ACTIVITY = "/start_activity";
2222
private static final String WEAR_MESSAGE_PATH = "/message";
@@ -36,7 +36,6 @@ protected void onCreate(Bundle savedInstanceState) {
3636

3737
init();
3838
initGoogleApiClient();
39-
sendMessage(START_ACTIVITY, "");
4039
}
4140

4241
private void initGoogleApiClient() {
@@ -94,4 +93,14 @@ public void run() {
9493
}
9594
}).start();
9695
}
96+
97+
@Override
98+
public void onConnected(Bundle bundle) {
99+
sendMessage(START_ACTIVITY, "");
100+
}
101+
102+
@Override
103+
public void onConnectionSuspended(int i) {
104+
105+
}
97106
}

WearMessageApi/wear/src/main/java/com/ptrprograms/wearmessageapi/MainActivity.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
import android.app.Activity;
44
import android.os.Bundle;
5+
import android.view.WindowManager;
56
import android.widget.ArrayAdapter;
67
import android.widget.ListView;
78

@@ -27,6 +28,8 @@ protected void onCreate(Bundle savedInstanceState) {
2728
mAdapter = new ArrayAdapter<String>( this, R.layout.list_item );
2829
mListView.setAdapter( mAdapter );
2930

31+
getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
32+
3033
initGoogleApiClient();
3134
}
3235

0 commit comments

Comments
 (0)