I am developing an application that makes use of NFC tags,
Is there a way to detect if the device it is running on has NFC ? and if it does not then i can display an alternative like possibly manually entering in the data rather than swiping the phone over the NFC tag?
If the phone has got the nfc feature then i would obviously ask them to turn it on if its currently disabled and then prompt them to swipe the tag.
Use the PackageManager :
getPackageManager().hasSystemFeature(PackageManager.FEATURE_NFC)
Related
While developing and servicing apps, there was development related to NFC.
In development, there is no problem getting the status value (on/off) of NFC.
I would like to ask if there is no way to know the current status other than registering and loading the broadcast when converting as a way to distinguish between p2p and card mode.
Most say do not, but Samsung Pay's card mode is recognized as having nfc turned on.
I want to ask if there is no way.
thank you
※ It can be awkward because it was written with a translator.
I want to implement an App to make user able to share specific data to a reader device without opening my App like applepay, googlepay airport passing passport
If the reader is only a true reading device and the only thing it expects to do is to read a NFC Tag (or a device pretending to be an NFC Tag, as in the case of your applepay, googlepay example).
Then on iOS what you want to do is not possible by you, Apple only allow themselves to do this.
On Android which has better NFC support it is possible to write a Host Card Emulation service that will run in the background that will pretend to be a NFC Tag. see the docs https://developer.android.com/guide/topics/connectivity/nfc/hce
I suggest reading Apple's docs on "Core NFC", the library that implements NFC in iOS.
I don't think you can do what you are asking to do. (You can't transmit an RFC tag while your app is suspended/quit or the phone is locked.)
A quick glance at those docs says that you can add support for background tag reading, and then have the "reader" start out by transmitting as an NFC tag. That would let you display a notification. Once the user taps the notification your app could be launched and notified. See the section titled "Adding Support for Background Tag Reading."
I have an android device which is locked in airplane mode. NFC is still enabled though. How can I program the NFC tag to turn off airplane mode?
I don't need alternative solutions, it has to be with an NFC tag.
I have tried {"status":"ok","actions":[{"action":"enable_wifi"},{"action":"setprop"}]}, I can see it's written on the NFC tag, but when I read it with the device, nothing changed.
Basically you can write anything to NFC tag and handle each value in your own app. So in general you can do whatever is allowed by Android framework.
Some sort of things are predefined by Android OS to handle. Depending on the type it can perform some actions (connect to wifi, open a browser, open a contact etc.) Check out the official documentationhere.
There are no predefined actions for toggling airplane mode or developers settings. These things are forbidden from the newest regular API.
So if you want to do something specific on tapping NFC tag
Check out how NFC tags are dispatched in Android
Write your own value to tag (writing and reading)
Handle your value on read
I want to be able to detect a simple NFC tag, and turn the phone on silence and then turn the silence off again, when the tag is removed. I have this all working when the phone is unlocked, but I need the app to work when the phone is locked. How would I go about getting this to work?
It's not possible to achieve this via your application alone. The core NFC service specifically forbids it. Users can either replace their NFC apk with one that does allow it, or install an Xposed module, but neither of those are something I would want to be instructing people to do, for security reasons.
Another downside would be the excessive battery usage due to the phone having to poll for NFC events.
It is possible?
I state that NFC is enabled on my phone and everything looks correct
I tried with an app called NFC TagWriter by NXP but don't work.
I create a tag with this app and then I tried to listen with other device but don't work, then I installed same app on the other device but don't work.
Please help me or suggested to me another way to do(share tag NFC).
THANKS!
The Android Beam™ feature allows a device to push an NDEF message onto another device by physically tapping the devices together. This interaction provides an easier way to send data than other wireless technologies like Bluetooth, because with NFC, no manual device discovery or pairing is required. The connection is automatically started when two devices come into range. Android Beam is available through a set of NFC APIs, so any application can transmit information between devices. For example, the Contacts, Browser, and YouTube applications use Android Beam to share contacts, web pages, and videos with other devices.
Reference from Developer Documentation
Also check this for Blog , it explains how to communicate between devices.
You can have (indepedent) p2p communication in 2 directions, and enableForegroundNdefPush is deprecated now; please, use setNdefPushMessage