I've probblem. My android wear emulator not show notification. Here is my code for mobile:
private void notifyToWear() {
NotificationCompat.WearableExtender wearableExtender = new NotificationCompat.WearableExtender()
.setHintShowBackgroundOnly(true);
NotificationCompat.Builder notificationBuilder = new NotificationCompat.Builder(this)
.setSmallIcon(R.drawable.ic_launcher)
.setContentTitle("Request text")
.setContentText("Speak something then your phone will search it.")
.extend(wearableExtender);
NotificationManagerCompat notificationManager = NotificationManagerCompat.from(this);
notificationManager.notify(0, notificationBuilder.build());
}
I call it when button in MainActivity click. In my phone it show notification but in android wear emulator not show. Notes: + I've connected between android phone & android wear emualtor. I tested with Card Example in Android Wear App. It's working.
Thanks.
-- Update -- Code perform click button:
(findViewById(R.id.btn_request_text)).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
Toast.makeText(MyActivity.this, "Call request", Toast.LENGTH_SHORT).show();
notifyToWear();
}
});
When I click to button Toast is show.
--- Update --- I also run ElizaChat & RecipeAssistant in Wear Sample. But it not working too.
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.
Try this:
NotificationCompact.Builder notBuilder =
new NotificationCompact.Builder(this);
notBuilder.setContentTitle("Title").setContentText("Text");
WearableNotifications.Builder wearBuilder =
new WearableNotifications.Builder(notBuilder);
Notification not = wearBuilder.build();
NotificationManagerCompat manager = NotificationManagerCompat.from(this);
manager.notify(0,not);
I hope this will help you..
来源:https://stackoverflow.com/questions/25641967/android-wear-not-show-notification