Android protocol handler not recognized by NFC - android

In my app, I have created a protocol handler for myapp://. This works perfectly. However, the NFC system does not seem to "recognize" it. When I create an NFC tag with the URI "myapp://test", instead of directly passing it to my app, the dialog "Choose an action" appears. I can then chose "New tag collected", select "myapp://test" and my application is started.
Is there anything I need to do additionally so that NFC directly opens my app?

You probably forgot to add the action "NDEF_DISCOVERED" to the intent filter in the Android manifest file.

You can solve this issue by adding an additional AAR record (special NDEF record = Android Application Record) to your tag. Subsequently, only your app is starting and nobody is asking anymore.
There are several apps available which create this android-applicationrecord for you.

Related

How to open wifi settings android with nfc tag?

I am making an android application that will open a page in the default android settings application.I understand that
android.provider.settings.ACTION_WIRELESS_SETTINGS
opens up the wifi settings . I need help implementing that as a message for the tag.
You can't store arbitrary Intents into an NFC tag; the system wouldn't know what to do with them. You'll need to write a custom payload that launches your application, and then your application will need to manually send the Intent based on your payload.
At a minimum, you'll want to store an AAR record, which will launch your app when the tag is scanned:
NdefMessage msg = new NdefMessage(
new NdefRecord[] {
...,
NdefRecord.createApplicationRecord("com.example.yourapp")}
From there, you can add additional NdefRecord entries to store whatever extra data you want.
As a practical matter, I recommend not storing the raw Intent as a record. Assuming you're not properly validating the input, somebody could write a similar tag that launches any Activity on the system, which seems at least mildly irresponsible.
More reading:
http://developer.android.com/guide/topics/connectivity/nfc/nfc.html#aar
http://developer.android.com/guide/topics/connectivity/nfc/nfc.html#creating-records

possible to launch android app via NFC with passing parameters

I wonder is it possible to not just simply launch an Android app (which we plan to develop ourselves allowing for that purpose) by having the NFC signal include some parameters and pass such parameters to the Android app via NFC so that, dependent on the parameter passed, e.g. a certain part of the app is accessed and/or the opening app automatically reads and saved the chips serial number?
Are such a more advanced features possible using NFC is is it limited just to "launch that app" and that's it?
THANKS A MILLION
Yes it is possible. You can define several criteria for launching the application. Once it is launched you can process in by the application code complete NDEF message.
It won't make any sense to start the application without passing the data - in such a case you will need anyway read the NFC tag or receive the NDEF over NPP/SNEP after the application will be started, so it is logical those information are already passed to the Intent.
BR
STeN
You should have a look at the Android Application Record. Placed it within an NDEF message, you can additionally add an External Type Record or some text-, uri-, or mimerecord depending on your needs. I have put together an NFC Eclipse plugin which should get you started.

Start Android application from NFC-tag with extra data

I can start my application by simply putting the phone on a NFC-tag. But I would like to take the idea one step further. Imagine a simple time-tracking application with two NFC-tags. The first will start (and download) the application and register a starttime. The other will also start (and download) the application, but register a stoptime.
My problem I'd like to solve is that I don't want my phone to know about these tags. The application should not need to have a list of tag-ids programmed and know what actions that is connected to each id. The tag should carry the information needed to start the action on the phone with the correct parameters.
Are there any information about how to accomplish this scenario? I have installed "nfc-eclipse-plugin" but doesn't understand how to use it to get my goal and even less how to get my application to read the extra data.
Thanks in advance
Roland
Your tags should be capable of storing NDEF messages. Such messages are automatically read out by Android and passed to your app in an Intent. Automatically installing and/or starting your app can be accomplished by putting an Android Application Record in your tag. Any additional information ("start" or "stop" indication) can be stored in a proprietary record.
You probably want to put the AAR as the last record of the NDEF message, as it is detected and acted upon by Android automatically, but is only supported since ICS. To make automatic installation work with Gingerbread, you can put an additional URI record or SmartPoster record with a Google Play Store link in it as the first record of the message. Your app should then filter (ACTION_NDEF_DISCOVERED) for this URI, so it will also start automatically on Gingerbread.

Android: New tag collected - Unknown tag type

I've made an application that scans tags with the NFC scanner. Instead of the default Tag app, my app starts when a card is read.
It works completely, but there's one thing that is rather annoying: when I scan a card very fast, my application don't seem to respond, but the default Tag app opens (see https://i.stack.imgur.com/lGwiM.png). Is there any way to disable the default app or to start my app quicker?
Go to settings -> Apps -> All -> Tags(in my case) -> disable it
I assume you filter for NDEF_DISCOVERED in your app currently and this is the case that works. If so, I would add a TECH_DISCOVERED intent for now, making sure you add a technology that your card supports so that your app can catch this corner case. From the logcat, I can't figure out what technology this tag is, so can't help you figure this out.
After your app can filter for TECH_DISCOVERED, read the data that is on the tag and see if it actually has the complete payload. If it doesn't then this would suggest the scan isn't picking up the entire payload and that moving your phone quickly away is a limitation of NFC itself. If the payload is the complete payload, then I would consider this a bug. Please report back.

Create NFC "Tag" object without a NFC phone?

When a NFC tag is brought closer in the vicinity of the phone, Android OS creates a NFC Tag object and starts the foreground dispatcher.
My problem, is that I don't have a NFC phone and I was trying to create my own tag object and start an intent which later on Android OS will take care to divert that intent to a particular app on my emulator.
Is it possible to create a NFC Tag object via code?
No, sorry. There is no way to emulate NFC effectively. I suggest that you wait on this application until you can acquire an NFC-capable Android device.
it is definitely possible to mimic an NFC tag being scanned. See
http://developer.android.com/resources/samples/NFCDemo/src/com/example/android/nfc/simulator/FakeTagsActivity.html
for an example. The NFC Demo sample that this class is in is somewhat dated and you need these libraries to compile it: http://code.google.com/p/guava-libraries/, but it should show you what you need to do.
You basically just need to create your NDEF message, specify that as an NFC intent extra (EXTRA_NDEF_MESSAGES) and specify the intent, such as ACTION_NDEF_DISCOVERED, and then call startActivity(intent).
#Sana
If you are developing on a windows system, i suggest you check out Open NFC.
In it is a Simulator tool which can be used to simulate NFC tags, but the only drawback is, the Android image that is emulated is Gingerbread and not ICS (which they are working, with haste is hope).
Otherwise, i have the same problem. I was wondering if someone with an NFC reader phone can write a simple code, which will simply persist the Tag Object so that people without an nfc reader can actually unserialize that object and use to simulate!
You can also duplicate the NDEF_DISCOVERED IntentFilter as a new IntentFilter that catches basicly the same thing.
Write the data you want to write in a tag in a QR code. And scan it. The phone will open the same activity with the same data. It will be kinda emulate the same reponse when you use an actual NFC tag.

Categories

Resources