×
Namespaces

Variants
Actions
(Difference between revisions)

How to read serial number of NDEF (NFC) tag

From Nokia Developer Wiki
Jump to: navigation, search
hamishwillee (Talk | contribs)
m (Hamishwillee - Adding missing translation link)
hamishwillee (Talk | contribs)
m (Hamishwillee - Bot update - Add ArticleMetadata)
Line 1: Line 1:
[[Category:Code Examples]][[Category:Java ME]][[Category:Near Field Communication (NFC)]]
+
{{ArticleMetaData <!-- v1.2 -->
 +
|sourcecode= <!-- Link to example source code e.g. [[Media:The Code Example ZIP.zip]] -->
 +
|installfile= <!-- Link to installation file (e.g. [[Media:The Installation File.sis]]) -->
 +
|devices= <!-- Devices tested against - e.g. ''devices=Nokia 6131 NFC, Nokia C7-00'') -->
 +
|sdk= <!-- SDK(s) built and tested against (e.g. [http://linktosdkdownload/ Qt SDK 1.1.4]) -->
 +
|platform= <!-- Compatible platforms - e.g. Symbian^1 and later, Qt 4.6 and later -->
 +
|devicecompatability= <!-- Compatible devices e.g.: All* (must have internal GPS) -->
 +
|dependencies= <!-- Any other/external dependencies e.g.: Google Maps Api v1.0 -->
 +
|signing= <!-- Signing requirements - empty or one of: Self-Signed, DevCert, Manufacturer -->
 +
|capabilities= <!-- Capabilities required by the article/code example (e.g. Location, NetworkServices. -->
 +
|keywords= <!-- APIs, classes and methods (e.g. QSystemScreenSaver, QList, CBase -->
 +
|language= <!-- Language category code for non-English topics - e.g. Lang-Chinese -->
 +
|translated-by= <!-- [[User:XXXX]] -->
 +
|translated-from-title= <!-- Title only -->
 +
|translated-from-id= <!-- Id of translated revision -->
 +
|review-by= <!-- After re-review: [[User:username]] -->
 +
|review-timestamp= <!-- After re-review: YYYYMMDD -->
 +
|update-by= <!-- After significant update: [[User:username]]-->
 +
|update-timestamp= <!-- After significant update: YYYYMMDD -->
 +
|creationdate= 20070524
 +
|author= [[User:Kevinauthor]]
 +
}}
 +
[[Category:Code Snippet]][[Category:Java ME]][[Category:Near Field Communication (NFC)]]
 
Near Field Communication (NFC) is a short-range wireless connectivity technology that offers simple, intuitive, and safe communication between electronic devices. Nokia is active in the area of NFC, and the company launched the world’s first [http://www.developer.nokia.com/Devices/Device_specifications/6131_NFC/ fully integrated NFC phone]
 
Near Field Communication (NFC) is a short-range wireless connectivity technology that offers simple, intuitive, and safe communication between electronic devices. Nokia is active in the area of NFC, and the company launched the world’s first [http://www.developer.nokia.com/Devices/Device_specifications/6131_NFC/ fully integrated NFC phone]
 
in January 2007.  
 
in January 2007.  

Revision as of 15:10, 18 July 2012

Article Metadata
Compatibility
Platform(s):
Series 40
Article
Created: kevinauthor (24 May 2007)
Last edited: hamishwillee (18 Jul 2012)

Near Field Communication (NFC) is a short-range wireless connectivity technology that offers simple, intuitive, and safe communication between electronic devices. Nokia is active in the area of NFC, and the company launched the world’s first fully integrated NFC phone in January 2007. This simple MIDlet can be used to read the serial number of an NDEF tag.

import javax.microedition.contactless.ContactlessException;
import javax.microedition.contactless.DiscoveryManager;
import javax.microedition.contactless.TargetListener;
import javax.microedition.contactless.TargetProperties;
import javax.microedition.contactless.TargetType;
import javax.microedition.lcdui.Display;
import javax.microedition.lcdui.Form;
import javax.microedition.lcdui.TextField;
import javax.microedition.midlet.MIDlet;
import javax.microedition.midlet.MIDletStateChangeException;
 
// Simple MIDlet to read the serial number of NDEF tag
public class ReadSerial extends MIDlet implements TargetListener {
 
private Form form;
private TextField textField;
 
protected void startApp() throws MIDletStateChangeException {
// Get instance of NFC Discovery Manager
DiscoveryManager dm = DiscoveryManager.getInstance();
 
// Register NDEF_TAG target to discovery
try {
dm.addTargetListener(this, TargetType.NDEF_TAG);
} catch (IllegalStateException e) {
// Catch IllegalStateException
} catch (ContactlessException e) {
// Catch ContactlessException
}
 
// Initialize and show user interface elements
form = new Form("ReadSerial");
textField = new TextField("Unique identifier:", "", 255, TextField.UNEDITABLE);
form.append(textField);
Display.getDisplay(this).setCurrent(form);
}
 
protected void pauseApp() {
}
 
protected void destroyApp(boolean arg0) throws MIDletStateChangeException {
}
 
public void targetDetected(TargetProperties[] prop) {
// Set unique identifier of the detected target on the Text Field
textField.setString(prop[0].getUid());
}
 
}
97 page views in the last 30 days.
×