简体   繁体   中英

read nfc tags written by other application

I am implementing two different application. 1) one will write content on nfc tag and read 2) Read content on tags only.

But while writing tag we have to mention the package because of which my second application is unable to read the tag. Is there any way to write tag in such a way my both applications can read. Any help or code snippet will be of great help.

Thanks.

I now this was written a while ago, and I hope you have figured out the answer by now, but if you haven't, here is the answer:

Create 2 separate NdefRecords with the 2 applications on it. Keep the MimeType to your original writing app name if you want to use that as an intent-filter (ie application/vnd.company.app).

So what you do is:

NdefRecord app1 = NdefRecord.createApplicationRecord(com.company.writer);
NdefRecord app2 = NdefRecord.createApplicationRecord(com.company.reader);

byte[] payload = xyz.getBytes();
byte[] mimeBytes = "com.company.writer".getBytes();
NdefRecord record = new NdefRecord(NdefRecord.TNF_MIME_MEDIA, mimeBytes, new byte[0], payload);
NdefMessage message = new NdefMessage(new NdefRecord[]{ record, app1, app2});

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM