Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Make Your Existing App Android Wear Compatible

Make Your Existing App Android Wear Compatible

Make Your Existing App Android Wear Compatible presented at jPrime conference which is held at Sofia, Bulgaria on 27th May.

Mert Simsek

May 27, 2015
Tweet

More Decks by Mert Simsek

Other Decks in Programming

Transcript

  1. If you send your notifications to your app, it appears

    on Wear, too!
 
 Only if you use NotificationCompat class
  2. Example pI = PendingIntent.getActivity(this, 0, new Intent(this,MainActivity.class), 0);
 pIExtra =

    PendingIntent.getActivity(this, 0, new Intent(Intent.ACTION_DIAL),0);
  3. Example NotificationCompat.Builder mBuilder =
 new NotificationCompat.Builder(this)
 .setSmallIcon(R.mipmap.ic_launcher)
 .setContentTitle("TEST")
 .setContentText("Test Mesasge!")


    .extend(new NotificationCompat.WearableExtender().addAction(action)); 
 mBuilder.setContentIntent(pI);
 mBuilder.setDefaults(Notification.DEFAULT_SOUND);
 mBuilder.setAutoCancel(true);
 NotificationManager mNotificationManager = (NotificationManager)this.getSystemService(Context.NOTIFICATION_SERVICE);
 mNotificationManager.notify(1, mBuilder.build());
  4. Example It will be shown on the handset as usual.

    But if an Android Wear is connected to the handset, it will be look like this! >
  5. Wear Emulator & Android Device Create an Android Wear emulator

    Install Android Wear app to your phone Connect your phone to your computer Open up Terminal and make the port forwarding via this command: 
 adb -d forward tcp:5601 tcp:5601 Run the Android Wear Emulator and select “pair with emulator” option from Android Wear app