SkillAgentSearch skills...

FudiNFC

:octocat: :credit_card: NFC Reader And Writer using Android devices by @romellfudi

Install / Use

/learn @romellfudi/FudiNFC

README

Gemini_Generated_Image_x46fykx46fykx46f

<h1 align="center"> Fudi NFC </h1>

Platform API License Bintray Data Studio Jitpack Android Arsenal

<!-- START doctoc generated TOC please keep comment here to allow auto update --> <!-- DON'T EDIT THIS SECTION, INSTEAD RE-RUN doctoc TO UPDATE --> <h1 align="center">Architecture Overview</h1> <img width="2816" height="1536" alt="Gemini_Generated_Image_gqnmj3gqnmj3gqnm" src="https://github.com/user-attachments/assets/81f1ab47-0aae-4600-8dd2-06b6a9658476" />

SNAPSHOT

<!-- END doctoc generated TOC please keep comment here to allow auto update -->

Author Romell Domínguez

Downloads Dashboard - latestVersion is

Data Studio

Add the following in your app's build.gradle file:

repositories {
    maven { url 'https://jitpack.io' }
}
dependencies {
    implementation 'com.github.romellfudi:FudiNFC:1.2.0'
}

Add the following to your AndroidManifest.xml file :

<uses-permission android:name="android.permission.NFC" />

Now go to the created activity, and either

  • Implement the callback actions
// write email
OpCallback { it.writeEmailToTagFromIntent(text, null, null, intent) }

// write sms message
OpCallback { it.writeSmsToTagFromIntent(text, null, intent) }

// write geolocation - latitude & longitude
OpCallback { it.writeGeolocationToTagFromIntent(latitude, longitude, intent) } 

// write uri
OpCallback { it.writeUriToTagFromIntent(text, intent) }

// write phone contact
OpCallback { it.writeTelToTagFromIntent(text, intent) }

// write rolling-on bluetooth device
OpCallback { it.writeBluetoothAddressToTagFromIntent(text, intent) }

How to read tags

Paste this in the activity if you're extending our class :

override fun onNewIntent(Intent intent) {
    super.onNewIntent(intent) 
    for (String message in getNfcMessages()) { 
        // message 
    }
}
  • Otherwise :
override fun onNewIntent(intent: Intent?) {
    super.onNewIntent(intent)
    val items: SparseArray<String> = NfcReadUtilityImpl().readFromTagWithSparseArray(intent)
    for (i in 0 until items.size()) {
        // items.valueAt(i) 
    }
}
  • If you like the Map implementation more you might as well use :
override fun onNewIntent(intent: Intent?) {
    super.onNewIntent(intent)
    for (message in NfcReadUtilityImpl().readFromTagWithMap(intent).values()) {
        // message
    }
}
  • Now you're able to read the NFC Tags as long as the library supports the data in it when held to your phone!

How to write into tags

  • Let your activity implement TaskCallback:
fun onReturn(result: Boolean) {
    val message = if (result) "Success" else "Failed!"
    Toast.makeText(this, message, Toast.LENGTH_SHORT).show()
}

fun onProgressUpdate(vararg booleans: Boolean) {
    Toast.makeText(this, if (booleans[0]) "We started writing" else "We could not write!", Toast.LENGTH_SHORT).show()
}

fun onError(e: Exception) {
    Toast.makeText(this, e.message, Toast.LENGTH_SHORT).show()
}

How to obtain tags' MAC

fun getMAC(tag: Tag): String{
    val byteArrayToHexString = String.format("%0" + (tag.id.size * 2).toString() + "X", BigInteger(1, tag.id))
    val regex = Regex("(.{2})")
    return regex.replace(byteArrayToHexString, "$1:").dropLast(1)
}
  • If you hold a tag near by the phone and NFC is Enabled, your implementation of the methods will be executed.

MAD SCORE

<p align="center"><img src="snapshot/summary.png" alt="summary"/></p> <p align="center"><img src="snapshot/kotlin.png" alt="kotlin"/></p> <p align="center"><img src="snapshot/nfc.gif" alt="nfc"/></p>

License

Copyright 2020 Romell D.Z.

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

Related Skills

View on GitHub
GitHub Stars124
CategoryDevelopment
Updated2mo ago
Forks28

Languages

Kotlin

Security Score

100/100

Audited on Jan 17, 2026

No findings