Skip to content

Instantly share code, notes, and snippets.

View salmangadit's full-sized avatar

Salman Gadit salmangadit

  • Microsoft
  • Silicon Valley
View GitHub Profile
@salmangadit
salmangadit / MifareUltralight
Created June 25, 2013 04:17
Android intent resolution for Mifare Ultralight
void resolveIntent(Intent intent) {
// 1) Parse the intent and get the action that triggered this intent
String action = intent.getAction();
// 2) Check if it was triggered by a tag discovered interruption.
if (NfcAdapter.ACTION_TECH_DISCOVERED.equals(action)) {
// 3) Get an instance of the TAG from the NfcAdapter
Tag tagFromIntent = intent.getParcelableExtra(NfcAdapter.EXTRA_TAG);
// 4) Get an instance of the Mifare ultralight card from this TAG
// intent
MifareUltralight mfc = MifareUltralight.get(tagFromIntent);
@salmangadit
salmangadit / Mifare Classic 1K
Created June 25, 2013 04:20
Android intent for Mifare Classic 1K
try {
// 5.1) Connect to card
mfc.connect();
boolean auth = false;
String cardData = null;
// 5.2) and get the number of sectors this card has..and loop
// thru these sectors
int secCount = mfc.getSectorCount();
int bCount = 0;
int bIndex = 0;