我正在尝试为Android设备创建通知。这是在手机上编写的代码。它会在手机上显示通知,但不会显示在 android wear 中。我错过了什么吗?
button.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
// Perform action on click
Log.i("Tag","Inside Self destruct");
//Code for notification begins here
PendingIntent pi = PendingIntent.getActivity(context, 0, new Intent(context, ShowNotificationDetailActivity.class), 0);
Resources r = getResources();
String greetingIdText = r.getString(R.string.notification_text);
Notification notification = new NotificationCompat.Builder(context)
.setTicker(r.getString(R.string.notification_title))
.setSmallIcon(android.R.drawable.ic_menu_report_image)
.setContentTitle(r.getString(R.string.notification_title))
.setContentText(greetingOne.getContent())
.setContentIntent(pi)
.setAutoCancel(true)
.build();
NotificationManagerCompat notificationManager = NotificationManagerCompat.from(context);
notificationManager.notify(0, notification);
}
});