发送通知到卵石 [英] Sending a Notification to Pebble
问题描述
我想通知发到我的小卵石的手表。我使用这个code,这基本上是从网站的例子:
I'm trying to send a notification to my pebble watch. I'm using this code, which is basically 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中的消息,但对手表没有通知。该过程似乎很简单,就是有什么太明显我错过了什么?或者是文档只是不完整?
I'm getting the message in LogCat, but no notification on the watch. The procedure seems simple enough, is there something too obvious I missed? Or is the documentation just incomplete?
编辑:最明显的问题:
- 是,手表连接
- 是的,我有第三方通知启用
推荐答案
好了,这是我的问题:
默认情况下,卵石程序只将通知发送到手表,而手机的屏幕是关闭的。对于发展中,我总是有屏幕活动,而手机通过USB连接。因此,将溶液:启用总是发送通知中的卵石应用程序选项
By default the Pebble app only sends notifications to the watch while the screen of the phone is off. For development I always have the screen active while the phone is connected via USB. So, the solution was: Enable the "Always send Notifications" option in the Pebble app.
也许这免去别人头疼。
这篇关于发送通知到卵石的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!