Android穿不显示通知
我有问题。我的android穿戴模拟器不显示通知。 这里是我的移动代码:Android穿不显示通知
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());
}
我把它当MainActivity点击按钮。在我的手机显示通知,但在Android穿模拟器不显示。 笔记: +我已连接Android手机& android wear emualtor。我使用Android Wear App中的卡片示例进行了测试。它正在工作。
谢谢。
- 更新 - 代码执行单击按钮:
(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();
}
});
当我点击按钮Toast是表演。
---更新--- 我也运行ElizaChat &食谱Assist in Wear Sample。 但它不工作。
确保你已经给到您的通知设备访问Android Wear应用。
在4.4:设置>安全>通知接入
输入L前瞻:设置>声音&通知>的通知接入
在该通知中访问屏幕,确保Android Wear检查。
非常感谢! 我有问题,为什么android开发者页面没有注意到它。 :( – quangson91 2014-09-09 04:19:52
WOW :)它真的是解决方案吗?为什么Android没有提到这个? – Elior 2014-09-13 19:27:27
感谢兄弟,我为此感慨万分。 – 2016-06-11 11:25:35
试试这个:
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);
我希望这将帮助你..
它仍然无效:| – quangson91 2014-09-03 22:50:11
你可以发布按钮的代码?看看你如何调用这段代码? – Elior 2014-09-03 10:39:48
我更新了问题。你能帮我吗 ? – quangson91 2014-09-03 10:44:12
看到我的答案.. – Elior 2014-09-03 11:42:32