original source:  https://developer.android.com/training/wearables/apps/layouts.html

Create Custom Notifications

ou should create notifications on the phone and let them automatically sync to the wearable.

Note: When creating custom notifications on the watch, you can use the standard notification APIs (API Level 20) instead of the Support Library.

1.Create a layout and set it as the content view for the activity that you want to display.

public void onCreate(Bundle bundle){

 2.in the Android manifest 

For example:

<activity android:name="com.example.MyDisplayActivity"
   android:theme="@android:style/Theme.DeviceDefault.Light" />

3.Create a PendingIntent for the activity that you want to display. 

Intent notificationIntent = new Intent(this, NotificationActivity.class);
PendingIntent notificationPendingIntent = PendingIntent.getActivity(
       this, 0, notificationIntent, PendingIntent.FLAG_UPDATE_CURRENT);

4.Build a Notification and call setDisplayIntent() providing the PendingIntent. The system uses this PendingIntent to launch the activity when users view your notification.

5.Issue the notification using the notify() method.

Create Layouts with the Wear UI Library

사용자 정의 layout을 만드는데 유용한 wear 에 특화된 ui library element

  • BoxInsetLayout  A FrameLayout object that’s aware of screen shape and can box its children in the center square of a round screen.
  • ConfirmationActivity  An activity that displays confirmation animations after the user completes an action.
  • AnimationSet  A group of animations that should be played together.
  • CircularProgressLayout  A layout that provides a circular countdown timer around a child view. Typically used as an automatic timer to confirm an operation after a short delay has elapsed.
  • PagerSnapHelper  Implementation of the SnapHelper instance supporting pager style snapping in either vertical or horizontal orientation.
  • ProgressBar  Displays a bar to the user representing how far the operation has progressed; the application can change the amount of progress (modifying the length of the bar) as it moves forward.

Comments are closed.

Post Navigation