Hallo,
> when i try to write to a mifare classic 1k card ,
> Ndef.get(tag) returns null, upon searching, i find that tag is not
> listed in tech list. but when i issue getTechList() command, i am able
> to find
> MifareClassic , NdefA and Ndefformatable are listed, so where am i
> missing.
So you are missing quite the obvious:
You can only access technologies of a tag if the tag supports them.
Thus, as your MF1K tag supports MifareClassic, NfcA and
NdefFormatable, you can only access this tag using these three
technologies. Therefore, as Ndef is not listed you can also not use it
to access the tag.
Usually tags supporting Ndef provide either NdefFormatable (if the tag
supports NDEF but has not been initialized to the NDEF format) or Ndef
(if the tag is already prepared for NDEF data). So you need to check
which of these two technologies is supported and then use the proper
one to write your NDEF message to the tag.
> MifareClassic mfc=MifareClassic.get(tagFromintent);
> boolean auth=false;
> try {
> String[] ttype=tagFromintent.getTechList();
> Ndef ndef1=Ndef.get(tagFromintent);
> mfc.connect();
> auth = mfc.authenticateSectorWithKeyA(0, MifareClassic.KEY_DEFAULT);
> } catch (IOException e1) {
So here you got another (potential) problem. You should not mix using
different technologies. Either use MifareClassic for access to the
tags raw data or use Ndef/NdefFormatable to get high-level access to
NDEF data.
br
Michael
--
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en