the url in code and jad
MIDlet-Push-1: ndef:rtd?name=urn:nfc:wkt:RFID_TAG,XXXXMidlet,nfc:ndef;type=simpletag;uid=*
Make sure you add the package name too in the MIDlet Push .jad file entry. For example:
MIDlet-Push-1: ndef:rtd?name=urn:nfc:wkt:RFID_TAG,com.nokia.nfc.sample.app.TestMidlet,nfc:ndef;type=simpletag;uid=*
This entry in the .jad file works just fine for me.
Why?
while in my example
Code:
iMessage += "getURL(\n"+properties[i].getUrl()+")\n"; // URL from TAG
= nfc:ndef;type=simpletag;uid=* -> * = UID
if * not correct then no install the midlet.
I think you confuse the url you use in your code to get a connection to a tag with the url that you add in your Push Registry entry.
The getUrl() method from TargetProperties returns the url that can be used to open a connection to a tag.
The url you specify in your .jad file when you register your entry for Push Registry is a different thing and this url (in your case "urn:nfc:wkt:RFID_TAG") needs to be written on the tag that you later use to launch the MIDlet.
To write this on your tag, you can use the following code:
Code:
private class WriteNdefThread implements Runnable {
public void run() {
long duration = System.currentTimeMillis();
boolean supported = false;
for (int i = 0; i < detectedTarget.length; i++) {
if (detectedTarget[i].hasTargetType(TargetType.NDEF_TAG)) {
supported = true;
try {
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:RFID_TAG");
NDEFRecord myRec;
myRec = new NDEFRecord(myType, null, fillAndReturnArray(contentlength, useNokiaContent));
NDEFRecord[] myRecArray = new NDEFRecord[] {myRec};
NDEFMessage myMessage = new NDEFMessage(myRecArray);
conn.writeNDEF(myMessage);
screenText2.setText("\n\n" + myMessage.toByteArray().length + " bytes written");
break;
} catch (ContactlessException e) {
} catch (IOException e) {
} catch (Exception e) {
}
}
}