Results 1 to 11 of 11
Thread: Java and NFC
- 06-29-2010, 03:38 PM #1
Member
- Join Date
- Jun 2010
- Posts
- 6
- Rep Power
- 0
Java and NFC
Hi,
i hope i have start this thread in the right section.
I have start with the theme nfc (near field communication) with this code:
Read serial number of NDEF (NFC) tag - Forum Nokia Wiki
that was simple.
But what i have to do, if i have more than one target to analyze?
For example in than way:
Java Code:public void targetDetected(TargetProperties[] prop) { if(prop[0].getUid().equals("9816628c")){ form.append("Option1"); form.append("\\NEXT CHOICE"); if(prop[1].getUid().equals("12e6a1d4")){ form.append("Option2"); } else{ form.append("FAILTURE2"); } } else{ form.append("FAILTURE"); } }
In this way the second tag, I can't analyze.
Any suggestions please ??
Thx nunuLast edited by nunu; 06-29-2010 at 06:41 PM.
- 06-29-2010, 05:03 PM #2
What is that piece of code supposed to do ?
What more do you want it to do?
Please use code tags to format your code to preserve indentation.
- 06-29-2010, 06:20 PM #3
Member
- Join Date
- Jun 2010
- Posts
- 6
- Rep Power
- 0
Sorry
My aim is to choice, between different tagets.
How i can format java code?
- 06-29-2010, 06:37 PM #4
What's a target? Is some part of the above a "target"?f(prop[0].getUid().equals("9816628c")){
Put [code ] and [/code ] without spaces around the code.
- 06-29-2010, 06:45 PM #5
Member
- Join Date
- Jun 2010
- Posts
- 6
- Rep Power
- 0
Thx,
is the second target, which choice with the device.if(prop[1].getUid().equals("12e6a1d4")){
but the targetlistner works only with prop[0].
I need to analyzed, one target, after one target.
- 06-29-2010, 06:53 PM #6
The args to the method is an array.TargetProperties[] prop
You can use a loop to look at each element in the array, index from 0 to prop.length-1
Replace prop[0] with prop[i] where i is the loop index.
- 06-29-2010, 07:02 PM #7
Member
- Join Date
- Jun 2010
- Posts
- 6
- Rep Power
- 0
This way I have try.
but every target is set on the first place prop[0].
- 06-29-2010, 07:50 PM #8
What is a "target"?every target is set on the first place prop[0].
What are in the rest of the elements in prop?
- 06-29-2010, 08:02 PM #9
Member
- Join Date
- Jun 2010
- Posts
- 6
- Rep Power
- 0
this is an example form the Nokia-Forum. (link in the first post)Java Code: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()); } }
- 06-29-2010, 08:25 PM #10
Sorry, your question seems to be about how to get info from some hardware device.
I'm just a java programmer and don't know anything about your hardware.
You'll have to read the doc for the device to see what to ask it to get the desired info.
- 06-29-2010, 08:44 PM #11
Member
- Join Date
- Jun 2010
- Posts
- 6
- Rep Power
- 0


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks