Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to read serial number of the nfc tag? #1

Closed
tony68hcm opened this issue Jun 29, 2020 · 2 comments
Closed

How to read serial number of the nfc tag? #1

tony68hcm opened this issue Jun 29, 2020 · 2 comments

Comments

@tony68hcm
Copy link

How to read serial number of the nfc tag?

@romellfudi
Copy link
Owner

Just read it from Intent variable paramIntent:

public override fun onNewIntent(paramIntent: Intent) {
...
}

@contactBoostTag
Copy link

contactBoostTag commented Aug 2, 2020

Hi @tony68hcm, @romellfudi, use the following lines:

// get their id
val tag = intent.getParcelableExtra(NfcAdapter.EXTRA_TAG) as Tag;
tag_id = tag.getId().toString();
// Finally
val regex = Regex("(.{2})")
val serial_id = regex.replace(ByteArrayToHexString(tag_id), "$1:").dropLast(1)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants