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.
Related
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.
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.
I read this question and another question and I understand how to launch an application from another application (Let's call the other application LauncherApplication). However, my goal is not only to launch an application, but to use its functions, so I suppose the LauncherApplication should start an activity using an intent (explicit or implicit).
I should know the data and the actions the installed applications react on and I should add these information to an intent instance before starting it. I wish LauncherApplication allows the user (not the developer) to configure this intent, but how do I know in advance the parameters to put in an intent for the installed applications?
I should implement the "LauncherApplication* in order to allow the user to construct an intent via a graphical interface. Or I could make my application supports the addition of plugins: in this way, I could create a plugin for each installed application, where each plugin could be responsible to manage the configuration of the intent concerning the application associated with it.
UPDATE (added details). In particular, the LauncherApplication should be a service with a speech recognizer enabled, so the user may start an application uttering specific keywords: as well as launch an application, the user should be able to close it and use its functions.
For example, I could have installed an application ((Let's call it LibraryApp) to search for available books in a library; this application could have the following functions:
Search for a book (this function may return if the book is available, it has already been loaned or if it was booked by someone else).
Reserving a book (this function should return the completion of the reservation).
In this way, when I pronounce, for example, the words "start LibraryApp", then the LauncherApplication service should launch the LibraryApp application. Once the application is launched, the service should be able to send commands to it to use one of the available functions (search for a book, reserving a book).
How can I send commands to application that is already active, in order to control it?
how do I know in advance the parameters to put in an intent for the installed applications?
You talk to their developers. There are typically zero "parameters" on an Intent to launch the launcher activity (or activities) of an application, since home screens do not put such "parameters" on the Intent.
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.
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.