5. “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
7. 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
9. The Context
Stream
Il Context Stream è
una lista verticale di Card
Nello stream viene visualizzata
una sola Card per volta.
developer.android.com/wear
14. Scarica il codice del codelab
al seguente link:
github.com/GDG-L-Ab/Wearun_ToDo
Code
15. 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
16. Tasto destro sulla libreria
-> build path
-> add to build path
Import
android.preview
Wearun/ libs/
Copiare la libreria:
wearable-preview-support.jar
18. 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
26. 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
27. @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
28. 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
29. 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