package com.njackson;

import com.getpebble.android.kit.PebbleKit;
import com.getpebble.android.kit.util.PebbleDictionary;

import android.content.Context;
import android.content.Intent;
import android.util.Log;

public class PebbleDataReceiver extends com.getpebble.android.kit.PebbleKit.PebbleDataReceiver {
	
	private static final String TAG = "PB-PebbleDataReceiver";
	
    public PebbleDataReceiver() {
        super(Constants.WATCH_UUID);
    }
    
    @Override
    public void receiveData(final Context context, final int transactionId, final PebbleDictionary data) {
        int button = data.getUnsignedInteger(Constants.CMD_BUTTON_PRESS).intValue();
        Log.d(TAG, "button: " + button);             
        PebbleKit.sendAckToPebble(context, transactionId);

        Intent i = new Intent(context, MainActivity.class);
        i.addFlags(
                Intent.FLAG_ACTIVITY_NEW_TASK   // If set, this activity will become the start of a new task on this history stack
              | Intent.FLAG_ACTIVITY_CLEAR_TOP  // If set, and the activity being launched is already running in the current task, then instead of launching a new instance of that activity, all of the other activities on top of it will be closed and this Intent will be delivered to the (now on top) old activity as a new Intent
              | Intent.FLAG_ACTIVITY_SINGLE_TOP // If set, the activity will not be launched if it is already running at the top of the history stack
        );
        i.putExtra("button", button);
        context.startActivity(i);
    }
}
@@ -578,15 +578,89 @@
     
+%09int  button = -1;%0A    %09if (data.contains(Constants.CMD_BUTTON_PRESS)) %7B%0A%09   
     
-int
  but
@@ -729,16 +729,17 @@
 alue();%0A
+%09
         
@@ -750,16 +750,44 @@
 d(TAG, %22
+Constants.CMD_BUTTON_PRESS, 
 button: 
@@ -802,22 +802,290 @@
 on);
+%0A
     
-         %0A
+%09%7D else if (data.contains(Constants.STATE_CHANGED)) %7B%0A    %09%09// old value, prior to v1.3%0A%09        button = data.getUnsignedInteger(Constants.STATE_CHANGED).intValue();%0A%09        Log.d(TAG, %22Constants.STATE_CHANGED, button: %22 + button);%0A    %09%7D    %09%0A    %09%0A    %09if (button %3E= 0) %7B%0A%09
     
@@ -1139,17 +1139,19 @@
 ionId);%0A
-%0A
+%09%0A%09
         
@@ -1202,16 +1202,17 @@
 class);%0A
+%09
         
@@ -1223,16 +1223,17 @@
 dFlags(%0A
+%09
         
@@ -1347,32 +1347,33 @@
 s history stack%0A
+%09
               %7C 
@@ -1685,16 +1685,17 @@
  Intent%0A
+%09
         
@@ -1836,16 +1836,17 @@
 y stack%0A
+%09
         
@@ -1848,16 +1848,17 @@
      );%0A
+%09
         
@@ -1883,24 +1883,25 @@
 %22, button);%0A
+%09
         cont
@@ -1922,15 +1922,22 @@
 ity(i);%0A
+    %09%7D%0A
     %7D%0A%7D

Add compatibility for old versions (reception of Constants.STATE_CHANGED)