2014-10-01 108 views
1

我已经创建了一个简单的应用程序。这将通知手持设备和可穿戴设备。以下是创建通知的代码在可穿戴模拟器上无法看到可穿戴通知

@Override 
public void onClick(View v) { 
    int notificationId = 001; 
    // Build intent for notification content 
    Intent viewIntent = new Intent(this, MainActivity.class); 
    PendingIntent viewPendingIntent = 
      PendingIntent.getActivity(this, 0, viewIntent, 0); 

    NotificationCompat.Builder notificationBuilder = 
      new NotificationCompat.Builder(this) 
      .setSmallIcon(R.drawable.ic_launcher) 
      .setContentTitle("title") 
      .setContentText("Location") 
      .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()); 
} 

我可以在手机上看到通知,但可穿戴模拟器不显示任何通知。

我按照以下步骤

  1. 创建穿戴式模拟器从Play商店

  2. 安装Android Wear应用程式。通过USB将手机连接到桌面

  3. 从“Android Wear”应用程序中使用“连接到模拟器”选项。演示卡可以在穿戴式模拟器上正确显示。
  4. 在手机上安装了我的应用程序(上面的代码)。触发通知。通知显示在手机上,但不在模拟器上。我观察到日志,但没有抛出异常

我在这里丢失了些什么。 迷你SDK级别的应用程序:8 目标SDK的应用:21

回答

1

我面临同样的问题和解决方案在设置 - >安全 - >通知接入,检查Android Wear允许它来阅读所有通知。

+0

谢谢!我会检查并让你知道结果。再次感谢:) – 2014-10-15 13:53:09

+0

嘿,谢谢,这解决了我的问题:) – 2014-11-06 12:12:03