I am creating an NFC application. I am a noob at Android this is my 2nd application. I was wondering if anyone knows how to create a message that erases the NFC tag. This function is seen in applications like TagWriter.
相关问题
- How can I create this custom Bottom Navigation on
- Bottom Navigation View gets Shrink Down
- How to make that the snackbar action button be sho
- Listening to outgoing sms not working android
- How to create Circular view on android wear?
相关文章
- android开发 怎么把图片放入drawable的文件夹下
- android上如何获取/storage/emulated/下的文件列表
- androidStudio有个箭头不认识
- SQLite不能创建表
- Windows - Android SDK manager not listing any plat
- Animate Recycler View grid when number of columns
- Why is the app closing suddenly without showing an
- Android OverlayItem.setMarker(): Change the marker
What exactly do you want to achieve? An NDEF message is a data packet that you store on an NFC tag, so "erasing" somewhat contradicts "creating an NDEF message". However, what you can do is create an NDEF message with a single empty NDEF record:
But keep in mind that writing this message to the tag will hide and partially overwrite any pre-existing NDEF messages on the tag, however it will not erase all data on the tag. For instance if a pre-existing message on the tag was longer than the new message, some parts of the old message's data may still remain stored on the tag.
So if you want to overwrite all data on the tag you might want to create a dummy record that contains as much data as can be stored on the tag (you can determine the maximum size of an NDEF message using
Ndef.getMaxSize()
, but you have to account for header bytes when creating your record). After writing that dummy record, you can again write the empty NDEF message as described above.