First of all, apologies for the lack of code within this question. It's purely for information to further develop my project.
I'm after using nfc tag technology with mobile phones, what I want to achieve is on scanning of an nfc tag, my local or cloud server is updated with the ID and time/date of scan.
I've looked on various forums, done countless searches on the web but for some reason cannot find a clear point to start from.
I'm comfortable with all web languages however I just can't get my head around the process, do you scan a given nfc tag which then loads a url with the ID of the tag in a get method.
Or is there something I can do within an app which will update the server on scan.
Again apologies.
A simple way is to store a URL in the NFC tag which points to your server application. You can add an ID to the URL, which identifies the tag towards the server. The timestamp can come from the server, when he receives the HTTP Request. Your server application can then store the ID together with the time.
This approach will not need any specific app on the mobile, any NFC capable phone will do that out of the box.
Should you need a local timestamp from the mobile phone, then will need an NFC app which takes the NFC intent, formes the proper URL including the locally generated data and send that off to your server.
Related
I have an android device with this app installed on it. Then have a second device that I have factory-reset. Both are NFC enabled. And I am trying to provision the second device with a device owner application. I want to understand how this works. I am under the impression that when I bump the two devices together, something should happen. However, nothing happens. Both devices are on and I believe that I am bumping them in the right places. I have not worked with NFC before.
On the NFCProvisioning app provided by Google, that I linked above, I can see that the wifi ssid, and password are set in the ndef message. However, the url to the deviceowner app is not set anywhere. How will the device being provisioned know how to download the apk?
Also what about this nfcprovisioning.txt? Please, can someone who has done this before help me out. Many thanks!
So Now I have more time I can give a full answer.
So some background on Android and NFC first.
The Android OS has some built in parsing and handling of some types of data on NFC cards, it will handle cards with NDEF messages on them.
When an NFC card is presented the OS will attempt to read and understand the card. If there is no App running that has expressed and interest in NFC NDEF messages it will handle some types of NDEF messages in certain was.
E.g. If the NDEF message contains record with the Mime Type saying "Web Address" the OS will launch a web browser (or ask the user which web browser to open the URL in)
An NDEF message can also contain an "Android Application Reference" or AAR record, this specifies a package name that should handle the data on the card. If that application is not installed it will open up google play to install it.
(https://developer.android.com/guide/topics/connectivity/nfc/nfc.html#aar)
Details on Mime Types and AAR at https://developer.android.com/guide/topics/connectivity/nfc/nfc.html#create-records
This is all done by they OS creating an Intent from the NDEF data and passing it to applications.
So more specific to NFCProvisioning creates an NDEF message of a special Mime Type "application/com.android.managedprovisioning" that Android Understands is about Device Provisioning and that to use a package name that is was given or "com.example.android.deviceowner" or "com.example.android.deviceowner/.DeviceOwnerReceiver" if non given.
The package name could be one found on the play store but it also has a option to specify a URL to download the management app package from.
There is other data included in the NDEF message to Like Wifi details, time zone etc will will be passed on the the Device provisioning app.
Details of what can be passed is at https://developer.android.com/reference/android/app/admin/DevicePolicyManager#MIME_TYPE_PROVISIONING_NFC I believe
The problem you might be suffering is that the method used for the Provisioner device uses to send the data is NfcAdapter#setNdefPushMessage http://developer.android.com/reference/android/nfc/NfcAdapter.html#setNdefPushMessage(android.nfc.NdefMessage,%20android.app.Activity,%20android.app.Activity...) which has been deprecated in API level 29/ Android 10 (and no longer works)
see the issues raised on this https://github.com/android/enterprise-samples/issues/27
I have not used this process before, but looking at the code the "nfcprovisioning.txt" is just a text file you can load in that stores the values of the key=value pairs instead of having to type them in to the App every time.
e.g. it would have lines like for that the data you want to provision
EXTRA_PROVISIONING_WIFI_SSID=someWifiSSid
I was reading this article about NFC and Kotlin and tried to implement the Code in my App. I want to send a string from one device (from the customer) to the receiving device (supplier) for a faster checking - in (for example if you have booked a table, the device reads the booking-id from the customer-app and displays the regarding information on the supplier-device.
The problem is that:
this.nfcAdapter?.setOnNdefPushCompleteCallback(outcomingNfcCallback, this)
this.nfcAdapter?.setNdefPushMessageCallback(outcomingNfcCallback, this)
both Callbacks from the NFC Adapter are deprecated since API 29.
So is there any other way left to do this?
Google's documentation mentions the following concerning the deprecation:
File sharing can work using other technology like Bluetooth.
Indicating the feature was originally intended for file sharing,
not the sending of short strings.
Two solutions come to mind:
On the customer's device you generate a QR code containing the string you want to send over. With the supplier's device you scan the QR code. This way is often used for mobile payment and customer reward/discount apps.
A web service where the customer sends over their ID and then information is returned from a database.
You can also combine these approaches by for example letting the customer scan a static printed QR code containing the supplier ID. With the supplier ID your app could then submit the customer's booking ID and the supplier ID to your web service after which booking info is returned.
I'm developing a django web-project and I'm going to develop its IOS and Android API.
Is there a way to avoid using hardcoded url addresses in the app code?Something like django url name system
The following problem faces me if there isn't any solution to my question:
If I want to change some of my urls, I should change the app code and also all the previous installed apps on peoples' devices won't work and should be updated.
The way I see it, you probably have two options:
a) Code very generic forwarding links into your app, such as:
http://www.example.com?linkid=1
http://www.example.com?linkid=2
You can then, from your side, forward these on to where you need them to go by using the query string ID number.
b) Write a web service to push updated URLs to your app, maybe on load so you're not polling the service all the time.
How often are the URLs likely to change?
I want to build an android app, that when you put your phone on nfc tag, the app connect to server (I suppose database will be in web server) and get the data from database, and when you put a phone on second nfc tag it connect again to server, but this time gets diffrent data from database(must be there new database).
So basically I' am new to servers and databases and if this is posible what I mention above or at least a similar. Can you provide me with some tutorials that I can learn from and will help me build this.
Please go through the following link,
http://developer.android.com/guide/topics/connectivity/nfc/index.html
It has all the tutorials on how to utilize NFC on Android. It has certain API's available as well which you can use. The part where first it does a different operation and the next time a different one all depends on you on how you deal with it. You can write a condition based on a boolean value to see if its a first time or second.
Hope this helps.
I am looking for a way to create a NFC-tag that shares the wifi credentials of my network without my guests having to have any special NFC apps on their phone (other than whats coming with the phone).
I have been looking at apps and services like NFC Tag Writer, WifiTap, NFC Task Launcher and NFCLabels.com, but it seems to me like it I would need to have the apps on the guest mobile as well to be able to use it, but I am not able to test it as I only have one NFC-enabled phone available. (Yes, I know, twisting my brains for nothing, but heck, weird behaviour is nothing new...)
My closest clue is that WifiTap states that:
The app processes URIs in the format of wifi://[network ssid]/[wep|wpa|open]/[network key]
If this is actually universal this would mean that I could do what I what I want to, but I have not found any confirmation on this. So, how could what I want be done and am I on the right track with the clue from WifiTap?
As Alex wrote in a comment, you can now (since Lollipop) write a tag containing Wi-Fi credentials directly from the Android Wi-Fi settings: long-tap a network → Write to NFC tag.
It seems to be an NDEF-formatted tag with the application/vnd.wfa.wsc MIME type and a "WPS NFC" token.
The relevant source code can be found in platform/packages/apps/Settings/src/com/android/settings/wifi/WriteWifiConfigToNfcDialog.java.
There is an official standard for this kind of situation: NFC Forum Connection Handover Technical Specification. However, this is currently not supported by Android. I don't think there is currently any way to transfer WiFi credentials using NFC without the help of a dedicated app.
One way of going about this is to create (or find) an app in the Google Play Store that has the following properties:
Intent filter for ACTION_NDEF_DISCOVERED and as URI the URL of the app in the Play Store.
Intent filter for ACTION_NDEF_DISCOVERED and as type some proprietary type (e.g. a MIME type)
Then you can create tags with an NDEF message containing the following NDEF records:
SmartPoster record with Play Store URI and some descriptive text (e.g. name of the app)
Record of proprietary type containing the WiFi credentials
Android Application Record for the app
The 3rd record will make sure that the proper app will always be started or the device user will be redirected to the Play Store to install it. This works only on ICS, however, but the 1st record (combined with the 1st intent filter) serves the same purpose on Gingerbread.
I've created an app which actually writes networks to tag in a standardized way - the problem is that Android does not currently recognize the handover records and automagically add them. And maybe that is all right - after all there is more to adding a network than just adding a network; you might for example verify the composer of the tag contents and so on.
Also, if you'd like to write more than one network to a tag, there might simply not be enough space to do it in the right (using standardized records) way.
I may have the wrong end of the stick but with the app nfc tools downloaded form the play store you can write a wifi network onto a tag that when scanned with defult android 5.0.2. On a nexus 7 2013 opens a message box asking confirmation formthe wifi connection, although this has always failed bar o
A URI of the form WIFI:T:WPA;S:SSID;P:PASSPHRASE;; will set WiFi if encoded to a QR code and scanned; but when encoded to an NFC tag it is unrecognized as a URI. This suggests to me that the NFC API is deficient in Android.