private void startWriteProcedure(Truck selectedTruck) throws JSONException {
   tagData = Util.getBaseTruckTagString(selectedTruck, false);
   libInstance = NxpNfcLibLite.getInstance();
   libInstance.registerActivity(this);
   libInstance.startForeGroundDispatch();
   showDialog("NFC READY", "tap the tag to write", DIALOG_TYPE_NOTIFY, ALERT_TYPE_FAILURE);
   //        mAdapter = NfcAdapter.getDefaultAdapter(this);
   //        mPendingIntent = PendingIntent.getActivity(this, 0, new Intent(this,
   // getClass()).addFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP), 0);
   //        if (mAdapter != null) {
   //            mAdapter.enableForegroundDispatch(this, mPendingIntent, null, null);
   //            showDialog("NFC READY","tap the tag to
   // write",DIALOG_TYPE_NOTIFY,ALERT_TYPE_FAILURE);
   //            Log.i("NDEF", "enable forground dispatch");
   //        }
 }
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_issue_truck_tag);

    Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);
    getSupportActionBar().setDisplayHomeAsUpEnabled(true);
    //
    libInstance = NxpNfcLibLite.getInstance();
    // intent filter directly picked from manifest
    libInstance.registerActivity(this);
    //        if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
    //            // Registering the activity for the NFC tag detection mode.
    //
    //            final Handler mLibhandler = new Handler(mLibhandlercb);
    //
    //            try {
    //                libInstance.setNfcControllerMode(1000, new NfcAdapter.ReaderCallback() {
    //
    //                    @Override
    //                    public void onTagDiscovered(final Tag tagObject) {
    //                        NxpLogUtils.d(TAG,
    //                                "TAG is Discovered from ReaderCallBack...");
    //
    //                        tag = tagObject;
    //                        mLibhandler.sendEmptyMessage(0);
    //
    //                    }
    //                }, NfcAdapter.FLAG_READER_NFC_A | NfcAdapter.FLAG_READER_NFC_V |
    // NfcAdapter.FLAG_READER_NFC_B | NfcAdapter.FLAG_READER_NFC_F );
    //            } catch (SmartCardException e) {
    //
    //            }
    //        }
    //
    if (DBOps.getAllTruckRegNo(this).size() == 0) {
      DBOps.insertNewTruck(
          this,
          new Truck(
              "TC1",
              "GA04J4008",
              "TCC1",
              "DC1",
              "GC1",
              "CARDID1000",
              "CAT1",
              new Date(),
              7000,
              3000));
      DBOps.insertNewTruck(
          this,
          new Truck(
              "TC2",
              "GA09J4567",
              "TCC2",
              "DC2",
              "GC2",
              "CARDID2001",
              "CAT2",
              new Date(),
              7000,
              4000));
      DBOps.insertNewTruck(
          this,
          new Truck(
              "TC3",
              "GA04J4444",
              "TCC3",
              "DC3",
              "GC3",
              "CARDID3002",
              "CAT3",
              new Date(),
              7000,
              5000));
    }
    initializeViews();
    getRegistrationNumbers();
    bindDataToAutoCompleteTextView();
  }