Android NFC İle Kart Bilgilerini Okuma
-
Merhaba arkadaşlar,
Android ile bir uygulama geliştirmekteyim.Bu uygulamada elımde bulunan kartlardan NFC ile karta data yazdırıp okuyabılıyorum.Ancak kartta bulunan Unique ID yi okuyamıyorum.Kartın ID sine ulaşabılmem ıcın ne yapmam lazım bu konuda yardımcı olabılecek varmı.
Teşekkürler
-
byte[] byte_id = intent.getByteArrayExtra(NfcAdapter.EXTRA_ID); cardId = Utils.convertbyteArrayToHexString(byte_id);
Utils classındaki method da bu:
public static String convertbyteArrayToHexString(byte in[]) { if (in == null) return null; byte ch = 0x00; int i = in.length - 1; String HEXSET[] = { "0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "A", "B", "C", "D", "E", "F" }; // Double length, as you're converting an array of 8 bytes, to 16 characters for hexadecimal StringBuffer out = new StringBuffer(in.length * 2); // You need to iterate from msb to lsb, in the case of using iCode SLI rfid while (i >= 0) { ch = (byte) (in[i] & 0xF0); // Strip off high nibble ch = (byte) (ch >>> 4); // shift the bits down ch = (byte) (ch & 0x0F); // must do this is high order bit is on! out.append(HEXSET[(int) ch]); // convert the nibble to a String Character ch = (byte) (in[i] & 0x0F); // Strip off low nibble out.append(HEXSET[(int) ch]); // convert the nibble to a String Character i--; } return (new String(out)); }
Toplam Hit: 1699 Toplam Mesaj: 2
