Send a custom notification to Pebble

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);
}
Publicité

Votre commentaire

Entrez vos coordonnées ci-dessous ou cliquez sur une icône pour vous connecter:

Logo WordPress.com

Vous commentez à l’aide de votre compte WordPress.com. Déconnexion /  Changer )

Photo Facebook

Vous commentez à l’aide de votre compte Facebook. Déconnexion /  Changer )

Connexion à %s

Articles récents
Commentaires récents
Catégories
Archives
%d blogueurs aiment cette page :