【发布时间】:2013-05-13 17:35:31
【问题描述】:
我正在尝试向我的卵石手表发送通知。我用的是这段代码,基本上是the example from the website:
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);
}
我在 LogCat 中收到消息,但手表上没有通知。该程序似乎很简单,我错过了一些太明显的东西吗?还是文档不完整?
编辑:显而易见的问题:
- 是的,手表已连接
- 是的,我启用了第三方通知
【问题讨论】:
-
我认为你需要在清单文件中声明
com.getpebble.action.SEND_NOTIFICATION,不确定,只是在想...... -
如果我理解正确,只有接收类必须这样做。
标签: java android pebble-watch pebble-sdk