Scroll Essential Android 2.3 Manual do Utilizador Página 19

  • Descarregar
  • Adicionar aos meus manuais
  • Imprimir
  • Página
    / 47
  • Índice
  • MARCADORES
  • Avaliado. / 5. Com base em avaliações de clientes
Vista de página 18
Android Wear Docs, Release 1.1
3.1.2 Modify the Handheld Activity
1. Import the the packages that support wearable features into the handheld Activity. As a minimum you need the
following notification packages:
import android.support.v4.app.NotificationManagerCompat;
import android.support.v4.app.NotificationCompat;
import android.support.v4.app.RemoteInput;
import android.app.Notification;
2. Add Android Wearable features to a Wearable extender object, for example ShowBackgroundOnly, to the on-
Create method.
NotificationCompat.WearableExtender wearableExtender =
new NotificationCompat.WearableExtender()
.setHintShowBackgroundOnly(true);
3. Create a normal Android notification using the NotificationCompat.Builder and set desired properties, including
those defined in the WearableExtender.
Notification notification =
new NotificationCompat.Builder(this)
.setSmallIcon(R.drawable.ic_launcher)
.setContentTitle("Hello Android Wear")
.setContentText("First Wearable notification.")
.extend(wearableExtender)
.build();
3. Optionally, apply a release 4.1 style to the normal notification, such as the one used in the Big Picture example
(NotificationCompat.BigPictureStyle).
4. Get an instance of the Notification Manager service.
NotificationManagerCompat notificationManager =
NotificationManagerCompat.from(this);
5. Dispatch the notification.
int notificationId = 1;
notificationManager.notify(notificationId, notification);
The result of this example is a notification with a title and body. If necessary, scroll through other notifications to view
this one.
3.1. First Android Wear Suggest 15
Vista de página 18
1 2 ... 14 15 16 17 18 19 20 21 22 23 24 ... 46 47

Comentários a estes Manuais

Sem comentários