向Pebble发送通知

Ger*_*der 1 java android pebble-watch pebble-sdk

我正在尝试向我的鹅卵石手表发送通知.我正在使用此代码,这基本上是来自网站的示例:

public void sendPebble(String title, String body) {
    final Intent i = new Intent("com.getpebble.action.SEND_NOTIFICATION");

    final Map<String, String> data = new HashMap<String, String>();
    data.put("title", title);
    data.put("body", body);

    final JSONObject jsonData = new JSONObject(data);
    final String notificationData = new JSONArray().put(jsonData).toString();
    i.putExtra("messageType", "PEBBLE_ALERT");
    i.putExtra("sender", "Test");
    i.putExtra("notificationData", notificationData);

    Log.d("Test", "Sending to Pebble: " + notificationData);
    sendBroadcast(i);
}
Run Code Online (Sandbox Code Playgroud)

我在LogCat中收到消息,但手表上没有通知.程序看起来很简单,有没有我错过的东西?或者文档是不完整的?

编辑:显而易见的问题:

  • 是的,手表是连接的
  • 是的,我启用了第三方通知

Ger*_*der 13

好的,这是我的问题:

默认情况下,Pebble应用程序仅在手机屏幕关闭时向手表发送通知.为了便于开发,我通常在通过USB连接手机时激活屏幕.因此,解决方案是:在Pebble应用程序中启用"始终发送通知"选项.

也许这让别人头疼.