Join Now
Quality Rating:
  • Currently 5.0 / 5
(5.0 / 5 - 1 vote cast)
Expertise Level:
  • Currently 0.0 / 5
(0.0 / 5 - 0 votes cast)

This page was last modified 18:29, 20 May 2008.

Read serial number of NDEF (NFC) tag

From Forum Nokia Wiki

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());
    }
    
}
Related Discussions
Thread Thread Starter Forum Replies Last Post
NDEF security matdacat Near Field Communication 0 2007-07-19 07:35
NFC and Mini RFID reading rakesh.pachawa Near Field Communication 1 2008-07-10 17:21
NMIT installation mmigdol General Browsing 3 2007-11-29 06:58
What are the operating modes of NFC devices? Natalia Aramayo Near Field Communication 1 2008-04-30 09:38
Communicate with external Mifare 4k eltria Near Field Communication 4 2007-11-12 11:52
 
Powered by MediaWiki
     
     RDF Facets:
     
     
     qfnZtopicQUqfnTopicZjavaQ
     qfnZtypeQUqfnTypeZCommunityContentQ
     qfnZtypeQUqfnTypeZWebpageQ
     qfnZtypeQUqfnTypeZWikiContentQ
     qmarsZlanguageQUxhttpE3aE2fE2fswE2enokiaE2ecomE2flanguageE2d1E2fenX