Created
January 13, 2014 11:50
-
-
Save togi/8399014 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version="1.0" encoding="utf-8"?> | |
<manifest xmlns:android="http://schemas.android.com/apk/res/android" | |
package="com.saftglas.pebble.cradle" > | |
<uses-permission android:name="android.permission.INTERNET" /> | |
<application | |
android:allowBackup="true" | |
android:icon="@drawable/ic_launcher" | |
android:label="@string/app_name" | |
android:theme="@style/AppTheme" > | |
<receiver | |
android:name="com.saftglas.pebble.cradle.PebbleDataBroadcastReceiver" | |
android:enabled="true" | |
android:exported="true" > | |
<intent-filter> | |
<action android:name="com.getpebble.action.app.RECEIVE" /> | |
</intent-filter> | |
</receiver> | |
</application> | |
</manifest> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.saftglas.pebble.cradle; | |
import android.content.Context; | |
import android.util.Log; | |
import com.getpebble.android.kit.PebbleKit; | |
import com.getpebble.android.kit.util.PebbleDictionary; | |
import java.util.UUID; | |
public class PebbleDataBroadcastReceiver extends PebbleKit.PebbleDataReceiver { | |
private TelldusAPI mTelldusApi = new TelldusAPI(); | |
public PebbleDataBroadcastReceiver() { | |
super(UUID.fromString("cd64334a-615d-4361-853e-f44f26e10295")); | |
} | |
@Override | |
public void receiveData(Context context, int transactionId, PebbleDictionary data) { | |
boolean on = data.getInteger(1) != 0; | |
mTelldusApi.sendRequest("device/" + (on ? "turnOn" : "turnOff"), Maps.<String, String>make("id", "361809"), new TelldusAPI.Callback() { | |
@Override | |
public void onComplete(String result) { | |
Log.d("", result); | |
} | |
@Override | |
public void onError(String description) { | |
Log.e("", description); | |
} | |
}); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment