@Override
  public void activate(Context context, int watchType) {
    if (appData != null) {
      Intent intent = new Intent("org.metawatch.manager.APPLICATION_ACTIVATE");
      Bundle b = new Bundle();
      b.putString("id", appData.id);
      intent.putExtras(b);
      context.sendBroadcast(intent);

      for (int button = 1; button < 6; ++button) {
        if (button == 3) continue; // don't override the LED button
        for (int type = 0; type < 4; ++type) {
          int code = 200 + ((button - 1) * 4) + type;
          int actualButton = button;
          // Gen2 watches have LED on top left rather than bottom left
          // button
          if (MetaWatchService.watchGen == MetaWatchService.WatchGen.GEN2) {
            if (actualButton > 3) actualButton++;
          } else {
            if (actualButton > 4) actualButton++;
          }

          Protocol.getInstance(context)
              .enableButton(actualButton, type, code, MetaWatchService.WatchBuffers.APPLICATION);
        }
      }
    }
  }
  @Override
  public void deactivate(Context context, int watchType) {
    if (appData != null) {
      Intent intent = new Intent("org.metawatch.manager.APPLICATION_DEACTIVATE");
      Bundle b = new Bundle();
      b.putString("id", appData.id);
      intent.putExtras(b);
      context.sendBroadcast(intent);

      for (int button = 1; button < 6; ++button) {
        if (button == 3) continue; // don't override the LED button
        for (int mode = 0; mode < 4; ++mode) {
          int actualButton = button;

          if (actualButton > 3) actualButton++;
          Protocol.getInstance(context)
              .disableButton(actualButton, mode, MetaWatchService.WatchBuffers.APPLICATION);
        }
      }
    }
  }
  public void deactivate(final Context context, int watchType) {
    if (Preferences.logging) Log.d(MetaWatch.TAG, "Leaving media mode");

    if (watchType == WatchType.DIGITAL) {
      Protocol.disableButton(1, 0, MetaWatchService.WatchBuffers.APPLICATION);

      Protocol.disableButton(2, 1, MetaWatchService.WatchBuffers.APPLICATION);

      Protocol.disableButton(5, 0, MetaWatchService.WatchBuffers.APPLICATION);
      // Protocol.disableButton(5, 1, MetaWatchService.WatchBuffers.APPLICATION);
      Protocol.disableButton(5, 2, MetaWatchService.WatchBuffers.APPLICATION);
      Protocol.disableButton(5, 3, MetaWatchService.WatchBuffers.APPLICATION);

      Protocol.disableButton(6, 0, MetaWatchService.WatchBuffers.APPLICATION);
      // Protocol.disableButton(6, 1, MetaWatchService.WatchBuffers.APPLICATION);
      Protocol.disableButton(6, 2, MetaWatchService.WatchBuffers.APPLICATION);
      Protocol.disableButton(6, 3, MetaWatchService.WatchBuffers.APPLICATION);
    } else if (watchType == WatchType.ANALOG) {
      Protocol.disableButton(0, 1, MetaWatchService.WatchBuffers.APPLICATION);
      Protocol.disableButton(0, 2, MetaWatchService.WatchBuffers.APPLICATION);
      Protocol.disableButton(2, 1, MetaWatchService.WatchBuffers.APPLICATION);
    }
  }
 private void initBuffer(Context context) {
   if (buffer == null) {
     buffer =
         Protocol.getInstance(context).createTextBitmap(context, "Starting application mode ...");
   }
 }
  public void activate(final Context context, int watchType) {
    if (Preferences.logging) Log.d(MetaWatch.TAG, "Entering media mode");

    if (watchType == WatchType.DIGITAL) {
      Protocol.enableButton(
          1, 0, TOGGLE, MetaWatchService.WatchBuffers.APPLICATION); // right middle - immediate

      Protocol.enableButton(
          2, 1, MENU, MetaWatchService.WatchBuffers.APPLICATION); // right bottom - press

      Protocol.enableButton(
          5, 1, VOLUME_DOWN, MetaWatchService.WatchBuffers.APPLICATION); // left middle - press
      Protocol.enableButton(
          5, 2, PREVIOUS, MetaWatchService.WatchBuffers.APPLICATION); // left middle - hold
      Protocol.enableButton(
          5, 3, PREVIOUS, MetaWatchService.WatchBuffers.APPLICATION); // left middle - long hold

      Protocol.enableButton(
          6, 1, VOLUME_UP, MetaWatchService.WatchBuffers.APPLICATION); // left top - press
      Protocol.enableButton(
          6, 2, NEXT, MetaWatchService.WatchBuffers.APPLICATION); // left top - hold
      Protocol.enableButton(
          6, 3, NEXT, MetaWatchService.WatchBuffers.APPLICATION); // left top - long hold
    } else if (watchType == WatchType.ANALOG) {
      Protocol.enableButton(0, 1, TOGGLE, MetaWatchService.WatchBuffers.APPLICATION); // top - press
      Protocol.enableButton(0, 2, MENU, MetaWatchService.WatchBuffers.APPLICATION); // top hold
      Protocol.enableButton(
          2, 1, NEXT, MetaWatchService.WatchBuffers.APPLICATION); // bottom - press		
    }
  }