Re: 6131 NFC autostart on tag touch
Dear all,
I am trying to make my application start upon tags touches.
I am using a 6212 and as tags the ones that come into the boc. I do not know which types are they :(
In the following there is the code I use for initialize the NFC and the push registry.
The application gets intalled and asks me for permission to autostart.
However, if I try to touch the tag when the application is not running, the app won't start, but the phone will read the tag as a note.
The tag simply contains a string "hello".
[CODE]
void initNFC()
{
dm = DiscoveryManager.getInstance();
try {
dm.addTargetListener(this, TargetType.NDEF_TAG);
dm.addNDEFRecordListener(this, new NDEFRecordType(
NDEFRecordType.MIME, "Text/Plain"));
PushRegistry.registerConnection("ndef:mime?name=Text/Plain",this.getClass().getName(), "*");
} catch (Exception e) {
form.append("EX: "+e.toString());
form.addCommand(exitCommand);
form.setCommandListener(this);
d.setCurrent(form);
}
}
[/CODE]
Any idea?
Re: 6131 NFC autostart on tag touch
Hi,
you need to create a tag with mime format as text/plain, since you are registering a push for that mime format.
please try with a static push entry in your application JAD file also. like "MIDlet-Push-1: ndef:mime?name=text/plain, com.yourcomp.yourmidlet, *"
regards
sunil
Re: 6131 NFC autostart on tag touch
[QUOTE=geri-m;414032]As far as I'm concerend the Emulator does not support the Auto-Launch/PushReg feature on tag-touch, as it also does not support OTA deploying. (Please let me know if I'm wrong ...)
Cheers, Gerald[/QUOTE]
I have got the emulator to work with push registry starting of an application.
I am using the 6212 Classic NFC emulator.
You have to set it to do "OTA" installation (Tools->Preferences->MIDP tab), so it goes through the Application Management System and is verified by JAM and INSTALLS the MIDlet in the emulator (i.e. stores it in the PC file system).
NOTE: I am still unable to get static push registry to work comletely on emulator nor handset (6212) but that is a different story. I have to start the app and have it programmatically register itself.
Then if you exit the MIDlet and go back to emulator's normal menu. If you attach a tag using the NFC manager your application will be started.
NOTE: I cannot get the recordDetected() method to be called on this auto-start, that's another issue I'm working on.
Re: 6131 NFC autostart on tag touch
[QUOTE=giaperrucci;555205]Dear all,
I am trying to make my application start upon tags touches.
I am using a 6212 and as tags the ones that come into the boc. I do not know which types are they :(
In the following there is the code I use for initialize the NFC and the push registry.
The application gets intalled and asks me for permission to autostart.
However, if I try to touch the tag when the application is not running, the app won't start, but the phone will read the tag as a note.
The tag simply contains a string "hello".
[CODE]
void initNFC()
{
dm = DiscoveryManager.getInstance();
try {
dm.addTargetListener(this, TargetType.NDEF_TAG);
dm.addNDEFRecordListener(this, new NDEFRecordType(
NDEFRecordType.MIME, "Text/Plain"));
PushRegistry.registerConnection("ndef:mime?name=Text/Plain",this.getClass().getName(), "*");
} catch (Exception e) {
form.append("EX: "+e.toString());
form.addCommand(exitCommand);
form.setCommandListener(this);
d.setCurrent(form);
}
}
[/CODE]
Any idea?[/QUOTE]
The tag with "Hello" is probably not a MIME type with "Text/Plain" but a tag with an NFC define "Text" RTD type.
So, your recordType you should register for would be NDEFRecordType.NFC_FORUM_RTD, "urn:nfc:wkt:T" where the "T" is for the Text RTD defined by NFC Forum.
Re: 6131 NFC autostart on tag touch
Hi everyone and thanks for your very helpful post!
I'm trying also to start the Midlet with my Tag, but I don't understand how to format a Tag in MIME format and which data corresponding to my Midlet I have to write in it...
Here's my code for writing my tag :
String url = detectedTarget[i].getUrl(Class.forName("javax.microedition.contactless.ndef.NDEFTagConnection"));
conn = (NDEFTagConnection) Connector.open(url);
NDEFRecordType myType = new NDEFRecordType(NDEFRecordType.NFC_FORUM_RTD,"urn:nfc:wkt:T");
NDEFRecord myRec;
myRec = new NDEFRecord(myType, null, data);
NDEFRecord[] myRecArray = new NDEFRecord[] {myRec };
NDEFMessage myMessage = new NDEFMessage(myRecArray);
conn.writeNDEF(myMessage);
But when I did so it doesn't launch my midlet but save a note with the byteArray data passed in myRec...
Could someone explain this MIME format thing? Thanks a lot
Antoine
Re: 6131 NFC autostart on tag touch
[QUOTE=Raluca_;311936]Yes, this is possible. Please see the following thread for information on how to do this:
[url]http://discussion.forum.nokia.com/forum/showthread.php?t=105707[/url]
Please let me know if you need more details.[/QUOTE]
Hello Raluca, I wanted to have something clear: Once my registered push application detects a matching target and NDEFRecord, will these NDEFRecord's get read immediately to display in a form? or should I touch the card again?
Re: 6131 NFC autostart on tag touch
[QUOTE=ant.pitel;713167]Hi everyone and thanks for your very helpful post!
I'm trying also to start the Midlet with my Tag, but I don't understand how to format a Tag in MIME format and which data corresponding to my Midlet I have to write in it...
Here's my code for writing my tag :
String url = detectedTarget[i].getUrl(Class.forName("javax.microedition.contactless.ndef.NDEFTagConnection"));
conn = (NDEFTagConnection) Connector.open(url);
NDEFRecordType myType = new NDEFRecordType(NDEFRecordType.NFC_FORUM_RTD,"urn:nfc:wkt:T");
NDEFRecord myRec;
myRec = new NDEFRecord(myType, null, data);
NDEFRecord[] myRecArray = new NDEFRecord[] {myRec };
NDEFMessage myMessage = new NDEFMessage(myRecArray);
conn.writeNDEF(myMessage);
But when I did so it doesn't launch my midlet but save a note with the byteArray data passed in myRec...
Could someone explain this MIME format thing? Thanks a lot
Antoine[/QUOTE]
Hi Ant, do you know if once my registered push application detects a matching target and NDEFRecord, will these NDEFRecord's get read immediately to display in a form? or should I touch the card again?
Re: 6131 NFC autostart on tag touch
Hallo,
[QUOTE=juancarlosr;736777]Do you know if once my registered push application detects a matching target and NDEFRecord, will these NDEFRecord's get read immediately to display in a form? or should I touch the card again?[/QUOTE]
Yes, these records are read on the first touch. Upon start your "NDEF pushed" application should immediately register an NDEFRecordListener for the record type that triggered the PushRegistry. Then the recordDetected(NDEFMessage) callback will receive the NDEFMessage that caused the application start.
br,
Michael
Re: 6131 NFC autostart on tag touch
Hallo ant.pitel,
[QUOTE=ant.pitel;713167]I'm trying also to start the Midlet with my Tag, but I don't understand how to format a Tag in MIME format and which data corresponding to my Midlet I have to write in it...
Here's my code for writing my tag :
[COLOR="Gray"][...][/COLOR]
NDEFRecordType myType = new NDEFRecordType(NDEFRecordType.NFC_FORUM_RTD,"urn:nfc:wkt:T");
NDEFRecord myRec;
myRec = new NDEFRecord(myType, null, data);
NDEFRecord[] myRecArray = new NDEFRecord[] {myRec };
NDEFMessage myMessage = new NDEFMessage(myRecArray);
conn.writeNDEF(myMessage);[/QUOTE]
The NFC Forum Well-known type urn:nfc:wkt:T (Text Record) and the MIME type text/plain are two different things. Therefore, you can either base your application on the Text record or on the text/plain MIME type.
For the Forum type Text Record, your PushRegistry entry would look something like this:
[CODE]MIDlet-Push-1: ndef:rtd?name=urn:nfc:wkt:T,your.MIDlet,*[/CODE]
You can then register an NDEFRecordListener for this NDEF record type in your application:
[CODE]dm.addNDEFRecordListener(this, new NDEFRecordType(NDEFRecordType.NFC_FORUM_RTD, "urn:nfc:wkt:T");[/CODE]
This should work for the NDEF message that you create with your code.
For the MIME type text/plain, your PushRegistry entry would look something like this:
[CODE]MIDlet-Push-1: ndef:mime?name=text/plain,your.MIDlet,*[/CODE]
You can then register an NDEFRecordListener for this NDEF record type in your application:
[CODE]dm.addNDEFRecordListener(this, new NDEFRecordType(NDEFRecordType.MIME, "text/plain");[/CODE]
br,
Michael
Re: 6131 NFC autostart on tag touch
Hi, I've been able to realize autolaunch by static registration in the Jad file.
I know that for autolaunching and reading the data of the ndef formatted tag, I need to implements NdefRecordListener interface.
according to the javadoc using NdefRecordListener is not possible to access the tag in write mode.
The application i'm developing need to:
1. autostart on tag touch
2. read data from the tag
3. do some computation on this data
4. write the updated data back to the tag
It shoul be done in just one interaction.
Right now i've done it simply implementig TargetListener, but in this way I need to touch the tag twice, is there a way to do everithyng in one touch.
Thanks and sorry for my bad english
Re: 6131 NFC autostart on tag touch
Hallo Simon,
[QUOTE=Simon-Italy;748769]according to the javadoc using NdefRecordListener is not possible to access the tag in write mode.[/QUOTE]
Right, the NDEFRecordListener allows for the phone implementation to receive & buffer the NDEF records. Thus, the NDEF message can be passed to an application even if the tag is no longer present.
[QUOTE=Simon-Italy;748769]Right now i've done it simply implementig TargetListener, but in this way I need to touch the tag twice, is there a way to do everithyng in one touch.[/QUOTE]
Sorry, but there is none. The reason for this is that touching a tag is meant to be a short operation. With the NDEFRecordListener it is not required that the tag is still present when the application reads the NDEF records. Therefore, no write operations can be allowed by the time the application processed the NDEF records.
br,
Michael
Re: 6131 NFC autostart on tag touch
Thanks Michael for your clear answer.