
Originally Posted by
mroland
Hallo,
Then, in the targetDetected event you just need to query your list which choice was selected by the user.
Austria...mountains, skiing, Mozart, Red Bull, ... but no kangaroos outside of a zoo ;-) It's 10 AM here.
br,
Michael
Im sorry Austria, im asleep, i know i know no kangaroos jumping there sorry, just read Aust and dont read more...sorry.
RBR are doing great job make F1 funny again but hope dont win all because if they won all, make so bored :P
About targetDetected, how can i do the query? i explain
Code:
public void targetDetected(TargetProperties[] properties) {
try {
TargetProperties target = properties[0]; // always at least one target
//open connection
MFStandardConnection conn = (MFStandardConnection) Connector.open(target.getUrl(MFStandardConnection.class));
MFSector mfsector = conn.getSector(sectorIndex);
MFBlock mfblock = mfsector.getBlock(blockIndex);
//name
byte[] KEY_SECTOR = {(byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF};
byte[] blockdata = new byte[mfblock.size()];
readcnt = mfblock.read(new MFKey.KeyA(KEY_SECTOR), blockdata, 0, 0, mfblock.size());
textField1.setString(new String(blockdata));
//passport
sectorIndex=1;
mfsector = conn.getSector(sectorIndex);
blockIndex=1;
mfblock= mfsector.getBlock(blockIndex);
byte[] KEY_SECTOR2 = {(byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF};
byte[] blockdata2 = new byte[mfblock.size()];
readcnt2 = mfblock.read(new MFKey.KeyA(KEY_SECTOR2), blockdata2, 0, 0, mfblock.size());
textField2.setString(new String (blockdata2));
//code
sectorIndex=1;
mfsector = conn.getSector(sectorIndex);
blockIndex=2;
mfblock= mfsector.getBlock(blockIndex);
byte[] KEY_SECTOR3 = {(byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF};
byte[] blockdata3 = new byte[mfblock.size()];
readcnt3 = mfblock.read(new MFKey.KeyA(KEY_SECTOR3), blockdata3, 0, 0, mfblock.size());
textField3.setString(new String (blockdata3));
//close connection
conn.close();
} catch (Exception e) {
textField1.setString("Scan Tag again");
} finally {
//closeQuietly(conn); //Importante: cerramos la conexion
}
}
That is the event when target are detected.
and this one is the list.
Code:
public void commandAction(Command arg0, Displayable arg1) {
try {
if (arg0.equals(cmdEnviar)) { //when push Enviar
elige = new List("Que hacer?: ", Choice.IMPLICIT);
elige.append("Leer", null); //Read
elige.append("Grabar", null); //Write
elige.append("Modificar", null);
elige.addCommand(cmdExit2);
elige.setCommandListener(this);
Display display = Display.getDisplay(this);
display.setCurrent(elige);
} else if (arg0.equals(cmdExit) || arg0.equals(cmdExit2)) {
this.notifyDestroyed();
} else if (arg0.equals(List.SELECT_COMMAND)) {
form.deleteAll();
form = new Form("Piloto Gestion NFC");
Ticker t = new Ticker("Piloto Gestion Residuos NFC");
form.setTicker(t);
textField1 = new TextField("Name ", "", 255, TextField.UNEDITABLE);
form.append(textField1);
textField2 = new TextField("passport ", "", 255, TextField.UNEDITABLE);
form.append(textField2);
textField3 = new TextField("Code ", "", 255, TextField.UNEDITABLE);
form.append(textField3);
form.setTitle("Hello Michael :P");
form.addCommand(cmdEnviar);
form.addCommand(cmdExit);
Display display = Display.getDisplay(this);
display.setCurrent(form);
}
} catch (Exception ex) {
}
}
So if i understand well, you said that for example put a flag (one integer (1-2)) that when the users, select write or read, change, then when targetDetected event trigger, ask for that integer, for example, not?