@Override
  public int onStartCommand(Intent intent, int flags, int startId) {
    DebugLogging.log(
        getApplicationContext(),
        (LOG_TAG
            + " onStartCommand handlerIsCreated "
            + handlerIsCreated
            + " "
            + (intent == null)));
    if ((intent != null)
        && (intent.getAction() != null)
        && (intent.getAction().equals(INSERT_DATA_ACTION))) {
      if (handlerIsCreated) {
        Message msg = thread.getHandler().obtainMessage();
        msg.arg1 = startId;

        msg.what = INSERT_DATA;
        msg.obj = intent.getExtras();
        thread.getHandler().sendMessage(msg);
      } else {
        needToSaveTransaction = true;
        bundle = intent.getExtras();
      }
    }

    return START_STICKY;
  }
 public void updateCardAlias(String cardsNumber, String alias) {
   Bundle bundle = new Bundle();
   bundle.putString(CARD_DATA, cardsNumber);
   bundle.putString(CARD_ALIAS_DATA, alias);
   Message msg = thread.getHandler().obtainMessage();
   msg.what = UPDATE_CARD_ALIAS;
   msg.obj = bundle;
   thread.getHandler().sendMessage(msg);
 }
 public void deleteAllData(boolean loadFromSMS) {
   Message msg = thread.getHandler().obtainMessage();
   if (loadFromSMS) {
     msg.what = DELETE_AND_LOAD_DATA_FROM_SMS;
     thread.getHandler().sendMessage(msg);
   } else {
     msg.what = DELETE_DATA;
     thread.getHandler().sendMessage(msg);
   }
 }
  @Override
  public void onCreate() {
    DebugLogging.log(getApplicationContext(), (LOG_TAG + " onCreate"));
    myDBAdapter = new MyDBAdapter(getApplicationContext());

    thread = new ServiceHandlerThread();
    thread.start();
  }
 public void deleteCardData(String cardNumber) {
   Message msg = thread.getHandler().obtainMessage();
   msg.what = DELETE_CARD;
   msg.obj = cardNumber;
   thread.getHandler().sendMessage(msg);
 }
 public void loadDataFromSMS() {
   Message msg = thread.getHandler().obtainMessage();
   msg.what = LOAD_DATA_FROM_SMS;
   thread.getHandler().sendMessage(msg);
 }
 public void getCardsData(String cardsNumber) {
   Message msg = thread.getHandler().obtainMessage();
   msg.what = GET_CARDS_DATA;
   msg.obj = cardsNumber;
   thread.getHandler().sendMessage(msg);
 }
 public void getBalance(String cardNumber) {
   Message msg = thread.getHandler().obtainMessage();
   msg.what = GET_BALANCE;
   msg.obj = cardNumber;
   thread.getHandler().sendMessage(msg);
 }
 public void getTransactionData(String filter) {
   Message msg = thread.getHandler().obtainMessage();
   msg.what = GET_TRANSACTION_DATA;
   msg.obj = filter;
   thread.getHandler().sendMessage(msg);
 }