开发者

Can NFC tags be protected from being overwritten?

开发者 https://www.devze.com 2023-02-26 06:18 出处:网络
The Nexus S can write to NFC tags. How do you stop anyone with a Nexus S from overwriting your tag?开发者_JAVA技巧

The Nexus S can write to NFC tags. How do you stop anyone with a Nexus S from overwriting your tag?

开发者_JAVA技巧

eg. If you have an NFC tag on a flyer that launches a video, can a guy with a Nexus S overwrite it and replace it with a link to his website?

Beginner here, just trying to get a handle on NFC, thanks!


Yes, many tag types permit write protection, some globally, and other more sophisticated ones by memory section inside the tag.

When you get your tag detected in your Android NFC app, then you can get a Tag object and read and write to the tag, including protecting it from further writing.

This is all described in the developer documentation for NFC classes on the Android developer site.

For example, if you are working at higher level and reading/writing Ndef messages:

  1. Setup an intent filter (in code or manifest) so you detect Ndef or NDefFormatable tags. You can get a Tag object from the Intent passed to you (in onCreate() or onNewIntent()).

    Tag tag = intent.getParcelableExtra( NfcAdapter.EXTRA_TAG );
    
  2. From your Tag try to get an Ndef tag object from the intent.

  3. If successful in getting an Ndef object from the tag, then check it is writable, check it has enough space, write to it and then use the makeReadOnly() of Ndef....

  4. If getting an Ndef object failed (exception) then you will need to format the Tag first....so... get an NdefFormattable object from the detected Tag and write a message to it and protect it, using the formatReadOnly(NdefMessage firstMessage), or just format it and then continue with code to get Ndef ...

  5. If you can't get an NdefFormattable object then something is seriously wrong, as that was what you requested in your filter. Formatting might fail if it is read-only already.

The developer documentation is not too bad, once you get your head around setting the IntentFilter by "Tag Technology" (including NdefFormatable and Ndef) and then getting those objects from the base Tag to do different operations.


Some NFC Tags can be configured to be read-only. Some are purchased with your data on them already, and set to read-only. http://www.radio-electronics.com/info/wireless/nfc/near-field-communications-tags-types.php


Yes, you can write-protect (most) tags, which inhibits others from overwriting your content. If you just want to write a tag, a good android app is NXP tagwriter, which has a variety of encoding options and a write-protect option.

If you want to make it so only you have control of your tag's content, try NFCLabels tag manager app. Your tag content is stored in the 'cloud', and you access your tag through your account. So you can write-protect a tag so Joe Schmoe can't blast your content, but you still have freedom to update your tag as needed. It also gives you some basic engagement analytics. Their youtube video shows how it works (see above link.)


Almost all of nfc tags can be protected by locked bits, which you can write an NFC tags with apps like NXP tagwriter, tasklauncher, make sure you have choose readonly options for encoding. Beside attention if an tag is read-only, it can not be rewritten again. For apps or nfc tags, go geenfc website for details.

0

精彩评论

暂无评论...
验证码 换一张
取 消