To send a custom notification to Pebble, you would do this:
Cocher la case Always Send Notification du menu « notification »
appeler sendAlertToPebble(); pour envoyer le message !
public void sendAlertToPebble() {
final Intent i = new Intent("com.getpebble.action.SEND_NOTIFICATION");
final Map data = new HashMap();
data.put("title", "Test Message");
data.put("body", "Whoever said nothing was impossible never tried to slam a revolving door.");
final JSONObject jsonData = new JSONObject(data);
final String notificationData = new JSONArray().put(jsonData).toString();
i.putExtra("messageType", "PEBBLE_ALERT");
i.putExtra("sender", "MyAndroidApp");
i.putExtra("notificationData", notificationData);
Log.d(TAG, "About to send a modal alert to Pebble: " %2B notificationData);
sendBroadcast(i);
}
Votre commentaire