Two questions:
My code:
int notificationId = 001;
// Reply action
Intent intent = new Intent(Intent.ACTION_VIEW);
intent.setData(Uri.parse("google.navigation:///?q=48.193479,11.569957&mode=w"));
PendingIntent actionPendingIntent = PendingIntent.getActivity(getApplicationContext(), 0, intent, PendingIntent.FLAG_UPDATE_CURRENT);
// Create the action
Notification.Action action =
new Notification.Action.Builder(R.drawable.map_white,
"Open Navigation", actionPendingIntent)
.build();
Notification notification =
new Notification.Builder(getApplicationContext())
.setPriority(Notification.PRIORITY_HIGH)
.setSmallIcon(R.drawable.map_icon_notification)
.setContentTitle("Navigation Notification")
.setContentText("Please swipe left to start navigation.")
.extend(new Notification.WearableExtender().addAction(action).setBackground(BitmapFactory.decodeResource(getApplicationContext().getResources(), R.drawable.background_notification)))
.setAutoCancel(true)
.build();
NotificationManagerCompat notificationManager =
NotificationManagerCompat.from(ListenerService.this);
notificationManager.notify(notificationId, notification);
Dismiss notification
notificationManager.cancel(notificationId)
In Android Wear, Notification icon is display your APP icon
AndroidManifest.xml
<application
android:allowBackup="true"
android:icon="@drawable/ic_launcher" <--- change this
android:label="@string/app_name"
android:theme="@style/AppTheme">
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.