Re: mifare Appid

Forum MIFARE SDK mifare Appid Re: mifare Appid

Re: mifare Appid

30. October 2014 at 16:29
The lite API actually doesn't have the limitation, you just need to approach the card in a different way.

In your manifest, add an intent-filter with action android.nfc.action.TAG_DISCOVERED for the activity

In the Activity class:
import com.nxp.nfclib.classic.MFClassic;
import com.nxp.nfcliblite.Interface.NxpNfcLibLite;

/**
* NXP NFC Library instance
*/
private NxpNfcLibLite nfcLibrary = null;

@Override
protected void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);

// Register the NXP NFC library; this is used to detect and read the cards
this.nfcLibrary = NxpNfcLibLite.getInstance();
this.nfcLibrary.registerActivity(this);
}

@Override
protected void onResume()
{
super.onResume();

this.nfcLibrary.startForeGroundDispatch();
}

@Override
protected void onPause()
{
super.onPause();

this.nfcLibrary.stopForeGroundDispatch();
}

@Override
protected void onNewIntent(Intent intent)
{
// Check if the received Intent action is an ACTION_TAG_DISCOVERED action
if(intent.getAction().equals(NfcAdapter.ACTION_TAG_DISCOVERED))
{
try
{
// Retrieve the Tag from the Intent
Tag tag = intent.getParcelableExtra(NfcAdapter.EXTRA_TAG);

// Check if the tag is a MFClassic tag
if(MFClassic.isClassic(tag))
{
// Convert the tag to a MFClassic object
MFClassic card = MFClassic.get(tag);

// Open a connection to the card
card.connect();

// Authenticate for a sector
card.authenticateSectorWithKeyA(sectorNumber, key);

// Read block
byte[] blockOutput = card.readBlock(blockNumber);

// Close connection to the card
card.close();
}
}
catch(ClassicException | IOException e)
{
e.printStackTrace();
}
}
}

Good luck!
+ 0  |  - 0