Example usage for android.nfc.tech IsoDep getTimeout

List of usage examples for android.nfc.tech IsoDep getTimeout

Introduction

In this page you can find the example usage for android.nfc.tech IsoDep getTimeout.

Prototype

public int getTimeout() 

Source Link

Document

Get the current timeout for #transceive in milliseconds.

Usage

From source file:com.example.multi_ndef.Frag_Write.java

public boolean varifyTag() {
    boolean test = false;

    byte[] NdefSelectAppliFrame = new byte[] { (byte) 0x00, (byte) 0xA4, (byte) 0x04, (byte) 0x00, (byte) 0x07,
            (byte) 0xD2, (byte) 0x76, (byte) 0x00, (byte) 0x00, (byte) 0x85, (byte) 0x01, (byte) 0x01 };

    byte[] CCSelect = new byte[] { (byte) 0x00, (byte) 0xA4, (byte) 0x00, (byte) 0x0C, (byte) 0x02, (byte) 0xE1,
            (byte) 0x03 };

    byte[] CCReadLength = new byte[] { (byte) 0x00, (byte) 0xB0, (byte) 0x00, (byte) 0x00, (byte) 0x0F };

    byte[] ndefSelectcmd = new byte[] { (byte) 0x00, (byte) 0xA4, (byte) 0x00, (byte) 0x0C, (byte) 0x02,
            (byte) 0x00, (byte) 0x01 // Ndef File ID to select
    };//from  w  w w.java2  s  .c  om

    //          int a = 491;

    byte[] ndefreadlengthcmd = new byte[] { (byte) 0x00, (byte) 0xB0, (byte) 0x00, (byte) 0x00, (byte) 0x6E };

    byte[] readBinary = new byte[] { (byte) 0x00, (byte) 0xB0, (byte) 0x00, (byte) 0x00, (byte) 0x0F };

    byte[] SYSSelect = new byte[] { (byte) 0x00, (byte) 0xA4, (byte) 0x00, (byte) 0x0C, (byte) 0x02,
            (byte) 0xE1, (byte) 0x01 };

    byte[] response1 = new byte[] { (byte) 0x01, (byte) 0x00, (byte) 0x00 };
    byte[] response2 = new byte[] { (byte) 0x01, (byte) 0x00, (byte) 0x00 };
    byte[] response3 = new byte[] { (byte) 0x01, (byte) 0x00, (byte) 0x00 };
    byte[] response4 = new byte[] { (byte) 0x01, (byte) 0x00, (byte) 0x00 };
    byte[] response5 = new byte[] { (byte) 0x01, (byte) 0x00, (byte) 0x00 };
    byte[] response6 = new byte[] { (byte) 0x01, (byte) 0x00, (byte) 0x00 };
    byte[] response7 = new byte[] { (byte) 0x01, (byte) 0x00, (byte) 0x00 };
    byte[] response8 = new byte[] { (byte) 0x01, (byte) 0x00, (byte) 0x00 };

    try {

        IsoDep isoDepCurrentTag = (IsoDep) IsoDep.get(ma.getCurrentTag());

        NfcA nfcaTag = (NfcA) NfcA.get(ma.getCurrentTag());
        nfcaTag.close();
        boolean a;
        a = isoDepCurrentTag.isConnected();
        byte[] at = new byte[10];
        //at=isoDepCurrentTag.getAtqa();
        isoDepCurrentTag.connect();
        int time;
        time = isoDepCurrentTag.getTimeout();

        response1 = isoDepCurrentTag.transceive(NdefSelectAppliFrame);
        response2 = isoDepCurrentTag.transceive(CCSelect);
        response3 = isoDepCurrentTag.transceive(CCReadLength);
        response4 = isoDepCurrentTag.transceive(SYSSelect);
        response5 = isoDepCurrentTag.transceive(readBinary);
        int ad = 10;
        isoDepCurrentTag.close();

    }

    catch (Exception e) {

        String exp = e.toString();
        Toast toast = Toast.makeText(getApplicationContext(),
                "Tag not found in range. Press back button and re click Write button", Toast.LENGTH_LONG);
        toast.setGravity(Gravity.CENTER | Gravity.CENTER, 0, 0);
        toast.show();

    }

    if (response5[8] == (byte) 0x02) {

        test = true;
    }

    else {

        test = false;

    }

    return test;
}