/* PebbleNotificationProfile.java Copyright (c) 2014 NTT DOCOMO,INC. Released under the MIT license http://opensource.org/licenses/mit-license.php */ package org.deviceconnect.android.deviceplugin.pebble.profile; import android.content.Intent; import org.deviceconnect.android.deviceplugin.pebble.PebbleDeviceService; import org.deviceconnect.android.deviceplugin.pebble.util.PebbleManager; import org.deviceconnect.android.profile.NotificationProfile; import org.deviceconnect.android.profile.api.DConnectApi; import org.deviceconnect.android.profile.api.PostApi; import org.deviceconnect.message.DConnectMessage; /** * Pebble用 Notification Profile. * @author NTT DOCOMO, INC. */ public class PebbleNotificationProfile extends NotificationProfile { private final DConnectApi mPostNotifyApi = new PostApi() { @Override public String getAttribute() { return ATTRIBUTE_NOTIFY; } @Override public boolean onRequest(final Intent request, final Intent response) { String b = getBody(request); // タグをタイトルとしておく // タグが設定されていない場合にはno titleを表示 String title = getTag(request); if (title == null) { title = " "; } if (b == null || b.length() == 0) { b = " "; } PebbleManager mgr = ((PebbleDeviceService) getContext()).getPebbleManager(); mgr.sendNotificationToPebble(title, b); setResult(response, DConnectMessage.RESULT_OK); //IDは取得できないので、処理のしようがない setNotificationId(response, "0"); return true; } }; public PebbleNotificationProfile() { addApi(mPostNotifyApi); } }