Your SlideShare is downloading. ×
"It's Time" - Android Wear codelab - GDG MeetsU - L'Aquila
Upcoming SlideShare
Loading in...5
×

Thanks for flagging this SlideShare!

Oops! An error has occurred.

×
Saving this for later? Get the SlideShare app to save on your phone or tablet. Read anywhere, anytime – even offline.
Text the download link to your phone
Standard text messaging rates apply

"It's Time" - Android Wear codelab - GDG MeetsU - L'Aquila

421

Published on

CodeLab from GDG MeetsU in L'Aquila, a Google Developer Group Roma Lazio-Abruzzo

CodeLab from GDG MeetsU in L'Aquila, a Google Developer Group Roma Lazio-Abruzzo

Published in: Software
0 Comments
2 Likes
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total Views
421
On Slideshare
0
From Embeds
0
Number of Embeds
2
Actions
Shares
0
Downloads
10
Comments
0
Likes
2
Embeds 0
No embeds

Report content
Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
No notes for slide

Transcript

  • 1. It’s Time Android Wear e Smartwatch: le app diventano indossabili Giuseppe Cerratti Alessandro Mancini e il Team del GDG Roma L-Ab
  • 2. Giuseppe Cerratti giuseppe.ciuffo@gmail.com it.linkedin.com/in/giuseppecerratti plus.google.com/+GiuseppeCerratti Alessandro Mancini alem1979@gmail.com it.linkedin.com/in/AleMan79 plus.google.com/+AlessandroMancini13
  • 3. developer.android.com/wear
  • 4. “Android wearables provide just the right information at just the right time, allowing you to be connected to the virtual world and present in the real world.” developer.android.com/wear Right info at right time
  • 5. Design Principales
  • 6. The Card Le Card sono alla base della UI di Android Wear Sono molto più che notifiche. Le Card appaiono solo se invocate o se strettamente necessarie all’utente in un certo istante. developer.android.com/wear
  • 7. The Card pattern App Laucher Icon Image Text Title developer.android.com/wear
  • 8. The Context Stream Il Context Stream è una lista verticale di Card Nello stream viene visualizzata una sola Card per volta. developer.android.com/wear
  • 9. How can I use it?!
  • 10. Plun! developer.android.com/wear
  • 11. Official devices Motorola moto360 LG G Watch
  • 12. Let’s Code!
  • 13. Scarica il codice del codelab al seguente link: github.com/GDG-L-Ab/Wearun_ToDo Code
  • 14. Caution: The current Android Wear Developer Preview is intended for development and testing purposes only, not for production apps. Google may change this Developer Preview significantly prior to the official release of the Android Wear SDK. Get the Developer Preview
  • 15. Tasto destro sulla libreria -> build path -> add to build path Import android.preview Wearun/ libs/ Copiare la libreria: wearable-preview-support.jar
  • 16. MainActivity.java import android.preview.support.wearable.notifications.*; import android.preview.support.v4.app.NotificationManagerCompat; import android.support.v4.app.NotificationCompat; Import android.preview
  • 17. int notificationId = 001; NotificationCompat.Builder notifBuilder = new NotificationCompat.Builder(getApplicationContext()) .setSmallIcon(R.drawable.ic_launcher) .setContentTitle("Lap Time") .setContentText("Swipe to save the lap time"); NotificationManagerCompat notificationManager = NotificationManagerCompat.from(getApplicationContext()); notificationManager.notify(notificationId,notifBuilder.build()); Build notification
  • 18. Test!
  • 19. Let’s Interact
  • 20. Create intent reciever public class NotificationReceiver extends BroadcastReceiver{ public static final String ACTION_START = "com.giux.wearun.ACTION_START"; @Override public void onReceive(Context context, Intent intent) { String action = intent.getAction(); MainActivity.start(); } }
  • 21. <application> <receiver android:name="com.giux.wearun.NotificationReceiver" android:exported="true" > <intent-filter> <action android:name="com.giux.wearun.ACTION_START"/> <action android:name="com.giux.wearun.ACTION_LAP"/> <action android:name="com.giux.wearun.ACTION_STOP"/> </intent-filter> </receiver> </application> Intent & manifest
  • 22. Intent intent = new Intent(NotificationReceiver.ACTION_START) .setClass(getBaseContext(), NotificationReceiver.class); PendingIntent pending = PendingIntent.getBroadcast(getBaseContext(), notifId, intent, 0); … .addAction(R.drawable.ic_start, "Start", pending ); …. addAction
  • 23. Test!
  • 24. Add another Action!
  • 25. public class NotificationReceiver extends BroadcastReceiver{ public static final String ACTION_START = "com.giux.wearun.ACTION_START"; public static final String ACTION_LAP = "com.giux.wearun.ACTION_LAP"; public static final String ACTION_STOP = "com.giux.wearun.ACTION_STOP"; Edit the Broadcast Reciever
  • 26. @Override public void onReceive(Context context, Intent intent) { String action = intent.getAction(); switch (action) { case ACTION_START: MainActivity.start(); break; … default: break; } Edit the Intent Reciever
  • 27. public PendingIntent createIntent(String extra, int notifId){ Intent intent = null; switch (extra) { case "start": intent = new Intent(NotificationReceiver.ACTION_START) .setClass(getBaseContext(), NotificationReceiver.class); break; … } PendingIntent pending = PendingIntent.getBroadcast(getBaseContext(), notifId, intent, 0); return pending; } More Intent
  • 28. public void notif(){ … .setContentTitle("Lap Time") .setContentText("Swipe to save the lap time") .addAction(R.drawable.ic_start, "Start", createIntent("start", notificationId)) //ToDo NotificationManagerCompat notificationManager = NotificationManagerCompat.from(getApplicationContext()); notificationManager.notify(notificationId, notifBuilder.build()); } More Action
  • 29. That’s All!

×