/**
   * Show toast with event information
   *
   * @param eventId The event id
   */
  public void doAction1(int eventId) {
    Log.d("doAction1 event id: " + eventId);

    // PaydVersionConfirm
    Intent intent = new Intent(this, PaydVersionConfirm.class);
    intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
    this.startActivity(intent);
    //		Cursor cursor = null;
    //		try {
    //			String name = "";
    //			String message = "";
    //			cursor = getContentResolver()
    //					.query(Notification.Event.URI, null,
    //							Notification.EventColumns._ID + " = " + eventId,
    //							null, null);
    //			if (cursor != null && cursor.moveToFirst()) {
    //				int nameIndex = cursor
    //						.getColumnIndex(Notification.EventColumns.DISPLAY_NAME);
    //				int messageIndex = cursor
    //						.getColumnIndex(Notification.EventColumns.MESSAGE);
    //				name = cursor.getString(nameIndex);
    //				message = cursor.getString(messageIndex);
    //			}
    //
    //			String toastMessage = getText(R.string.action_event_1)
    //					+ ", Event: " + eventId + ", Name: " + name + ", Message: "
    //					+ message;
    //			Toast.makeText(this, toastMessage, Toast.LENGTH_LONG).show();
    //		} finally {
    //			if (cursor != null) {
    //				cursor.close();
    //			}
    //		}
  }
  private void getFeed(String t, int count) {

    GmailFeed gf = new GmailFeed();
    gf.accessFeed(t, account);

    SharedPreferences pref = getSharedPreferences(account, 0);
    Editor e = pref.edit();
    unreadcount = gf.getUnreadcount();
    e.putInt("count", unreadcount);
    e.commit();

    List<GmailFeedBean> gfList = gf.getGfList();

    Log.d("count :" + count);
    if (gfList.size() > 0) {
      int j = (count > gfList.size() ? gfList.size() : count);

      for (int i = j - 1; i >= 0; i--) {
        GmailFeedBean gfs = gfList.get(i);

        SharedPreferences appprefs = PreferenceManager.getDefaultSharedPreferences(this);

        StringBuilder sbf = new StringBuilder();
        sbf.append((gfs.getName() == null ? gfs.getEmail() : gfs.getName()));

        if (gfs.getName() != null && !appprefs.getBoolean("hide_from", false)) {
          sbf.append((gfs.getEmail() == null ? "" : "<" + gfs.getEmail() + ">"));
        }

        StringBuilder sbs = new StringBuilder();
        sbs.append(
            (gfs.getTitle() == null
                    ? ""
                    : "<" + getString(R.string.subject) + ":" + gfs.getTitle() + ">")
                + "\n");

        StringBuilder sbb = new StringBuilder();
        sbb.append((gfs.getSummary() == null ? "" : gfs.getSummary()));
        sbb.append("\nto:" + account + "\nGmail Received. unread:" + unreadcount);

        sendAnnounce(sbf.toString(), gfs.getEmail(), sbs.toString(), sbb.toString());
      }
    } else {
      sendAnnounce(account, "Gmail Received. unread:" + unreadcount + "\nRequest TimeOut.");
    }
  }
  /**
   * {@inheritDoc}
   *
   * @see android.app.Service#onStartCommand()
   */
  @Override
  public int onStartCommand(Intent intent, int flags, int startId) {
    int retVal = super.onStartCommand(intent, flags, startId);

    Log.initialize(this);

    Log.d(" GmailExtensionService onStartCommand ");

    if (intent == null) {
      Log.d("intent is null.");
      return START_NOT_STICKY; // FIXME: onStartCommand の戻り値はいったい?
    }

    Bundle extras = intent.getExtras();

    SharedPreferences appprefs = PreferenceManager.getDefaultSharedPreferences(this);

    if (extras == null) {
      Log.d("extras is null.");
      return START_NOT_STICKY; // FIXME: onStartCommand の戻り値はいったい?
    } else {

      if ("^^unseen-^i".equals(extras.getString("tagLabel"))) {
        Editor e = appprefs.edit();
        e.putBoolean("tagLabel", true);
        e.commit();
        Log.d("tagLabel ^i isTrue ");
      }
      String extrasStr = "";
      Set<String> set = extras.keySet();
      for (String str : set) {
        Log.d("extras:" + str + ":" + extras.get(str).toString());
        extrasStr = "extras:" + str + ":" + extras.get(str).toString() + "\n";
      }

      Log.d(extrasStr);
    }

    if (appprefs.getBoolean("tagLabel", false)
        && "^^unseen-^iim".equals(extras.getString("tagLabel"))) {
      Log.d("tagLabel ^iim && ^i isTrue ");
      return START_NOT_STICKY; // FIXME: onStartCommand の戻り値はいったい?
    }

    // count の数から新着判定
    account = extras.getString("account");
    unreadcount = extras.getInt("count");

    SharedPreferences pref = getSharedPreferences(account, 0);
    int prev = pref.getInt("count", 0);
    Editor e = pref.edit();
    e.putInt("count", unreadcount);
    e.commit();

    if (prev < extras.getInt("count")) {

      String t = appprefs.getString(account + "_", "");

      if ("".equals(t)) {
        Log.d("sendAnnounce!");
        sendAnnounce(account, "Gmail Received. unread:" + unreadcount);
      } else {

        getFeed(t, unreadcount - prev);
      }
    }

    return retVal;
  }
 /**
  * {@inheritDoc}
  *
  * @see android.app.Service#onCreate()
  */
 @Override
 public void onCreate() {
   super.onCreate();
   Log.d("onCreate");
 }
 /**
  * Called when extension and sources has been successfully registered. Override this method to
  * take action after a successful registration.
  */
 @Override
 public void onRegisterResult(boolean result) {
   super.onRegisterResult(result);
   Log.d("onRegisterResult");
 }
 /**
  * {@inheritDoc}
  *
  * @see android.app.Service#onDestroy()
  */
 @Override
 public void onDestroy() {
   super.onDestroy();
   Log.d("onDestroy");
 }