Reputation: 427
I am working through the Creating notification tutorial and I wanted to know if the below code should live in the mobile
package or the wear
package?
int notificationId = 001;
// Build intent for notification content
Intent viewIntent = new Intent(this, ViewEventActivity.class);
viewIntent.putExtra(EXTRA_EVENT_ID, eventId);
PendingIntent viewPendingIntent =
PendingIntent.getActivity(this, 0, viewIntent, 0);
NotificationCompat.Builder notificationBuilder =
new NotificationCompat.Builder(this)
.setSmallIcon(R.drawable.ic_event)
.setContentTitle(eventTitle)
.setContentText(eventLocation)
.setContentIntent(viewPendingIntent);
// Get an instance of the NotificationManager service
NotificationManagerCompat notificationManager =
NotificationManagerCompat.from(this);
// Build the notification and issues it with notification manager.
notificationManager.notify(notificationId, notificationBuilder.build());
I also am debugging this locally with an actual android device and a wear emulator. Should I be expecting the notification to be propagated from the phone to the wear device in this setup?
Upvotes: 0
Views: 1024
Reputation: 179
Seems like a duplicate of Android wear not show notification
Make sure that you have given the Android Wear app on your device access to notifications.
In 4.4: Settings > Security > Notification Access
In L Preview: Settings > Sound & Notifications > Notification Access
Within the Notification access screen, make sure that Android Wear is checked.
Upvotes: 1
Reputation: 76
You want your phone to send the notification to the "wear" device, then it as to live in your "mobile" package.
This is the "normal" way.
Sometimes you want to create in context notification and in this case you need to write a "wear" activity or service to generate them.
Upvotes: 1