Hi all

I am trying to write Ndef message into Mifare Ultralight Tag.
But I am getting following error:

05-12 17:50:04.686: INFO/ActivityManager(121): Starting: Intent {
act=android.nfc.action.NDEF_DISCOVERED dat=tel:xxx-xxx-xxxx flg=0x30000000
cmp=com.android.apps.tag/.WriteTagActivity (has extras) } from pid -1
05-12 17:50:04.799: ERROR/com.android.apps.tag.WriteTagActivity(566): Failed
to write tag
05-12 17:50:04.799: ERROR/com.android.apps.tag.WriteTagActivity(566):
java.io.IOException: Tag is not ndef
05-12 17:50:04.799: ERROR/com.android.apps.tag.WriteTagActivity(566):     at
android.nfc.tech.Ndef.writeNdefMessage(Ndef.java:211)
05-12 17:50:04.799: ERROR/com.android.apps.tag.WriteTagActivity(566):     at
com.android.apps.tag.WriteTagActivity.writeTag(WriteTagActivity.java:173)
05-12 17:50:04.799: ERROR/com.android.apps.tag.WriteTagActivity(566):     at
com.android.apps.tag.WriteTagActivity.onNewIntent(WriteTagActivity.java:136)
05-12 17:50:04.799: ERROR/com.android.apps.tag.WriteTagActivity(566):     at
android.app.Instrumentation.callActivityOnNewIntent(Instrumentation.java:1119)
05-12 17:50:04.799: ERROR/com.android.apps.tag.WriteTagActivity(566):     at
android.app.ActivityThread.deliverNewIntents(ActivityThread.java:1722)
05-12 17:50:04.799: ERROR/com.android.apps.tag.WriteTagActivity(566):     at
android.app.ActivityThread.performNewIntents(ActivityThread.java:1734)
05-12 17:50:04.799: ERROR/com.android.apps.tag.WriteTagActivity(566):     at
android.app.ActivityThread.handleNewIntent(ActivityThread.java:1742)
05-12 17:50:04.799: ERROR/com.android.apps.tag.WriteTagActivity(566):     at
android.app.ActivityThread.access$2300(ActivityThread.java:117)
05-12 17:50:04.799: ERROR/com.android.apps.tag.WriteTagActivity(566):     at
android.app.ActivityThread$H.handleMessage(ActivityThread.java:978)
05-12 17:50:04.799: ERROR/com.android.apps.tag.WriteTagActivity(566):     at
android.os.Handler.dispatchMessage(Handler.java:99)
05-12 17:50:04.799: ERROR/com.android.apps.tag.WriteTagActivity(566):     at
android.os.Looper.loop(Looper.java:123)
05-12 17:50:04.799: ERROR/com.android.apps.tag.WriteTagActivity(566):     at
android.app.ActivityThread.main(ActivityThread.java:3683)
05-12 17:50:04.799: ERROR/com.android.apps.tag.WriteTagActivity(566):     at
java.lang.reflect.Method.invokeNative(Native Method)
05-12 17:50:04.799: ERROR/com.android.apps.tag.WriteTagActivity(566):     at
java.lang.reflect.Method.invoke(Method.java:507)
05-12 17:50:04.799: ERROR/com.android.apps.tag.WriteTagActivity(566):     at
com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
05-12 17:50:04.799: ERROR/com.android.apps.tag.WriteTagActivity(566):     at
com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
05-12 17:50:04.799: ERROR/com.android.apps.tag.WriteTagActivity(566):     at
dalvik.system.NativeStart.main(Native Method)
05-12 17:50:04.799: INFO/com.android.apps.tag.WriteTagActivity(566): in
onResume() mAdapter!=null
05-12 17:50:04.912: ERROR/NFC JNI(248): phLibNfc_RemoteDev_CheckPresence()
returned 0x00ff[NFCSTATUS_FAILED]


I had enabled WriteTagActivity.java and was trying the write application.
Problem is that the code block from where this IOException is occuring tells
me that the tag is already Ndef formatted.

heres the block  which gets excecuted:

Ndef ndef = Ndef.get(tag);
            if (ndef != null) {
                ndef.connect();
                if (!ndef.isWritable()) {
                    setStatus("Tag is read-only.", false);
                    return false;
                }
                if (ndef.getMaxSize() < mSize) {
                    setStatus("Tag capacity is " + ndef.getMaxSize() + "
bytes, message is " +
                            mSize + " bytes.", false);
                    return false;
                }
                ndef.writeNdefMessage(mMessage);
                setStatus("Wrote message to pre-formatted tag.", true);
                return true;


Since ndef!=null block is getting executed, i presume its already ndef
formatted.
I don't get "Tag is read-only." or "Tag capacity is " errors..
Exception is happening  when ndef.writeNdefMessage(mMessage) is executed

Let me know if anyone knows why this error is occuring.

Thanks & Regards,
Ajith

-- 
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

Reply via email to