
Originally Posted by
aaatul.paliwal@gmail.com
Hi....
Thanks for your reply.
Sometimes when i am not getting any value from the card, it shows the exception TARGETLOST. it means it connect to card but can't find unique tag (UID)of the Mifare Card.
i have one more query also. i am doing lots of process in the same application. like connected with Web Services, integration of bluetooth hardware with our application. Is it is possible there are so many process that by application sometimes could not find the card unique id??
I am sharing the code for read the RFID_TAG. plz give me the solution as soon as possible. i am waiting for positive response from your side...
''''''''''''''''''''''for standard connection'''''''''''''''''''''''
public MFStandardConnection getMFStandardConnection(TargetProperties[] tProp)
{
for (int j = 0; j < tProp.length; j++)
{
Class[] connections = tProp[j].getConnectionNames();
if(connections != null)
{
for (int i = 0; i < connections.length; i++)
{
if (connections[i].getName().equals("com.nokia.nfc.nxp.mfstd.MFStandardConnection"))
{
try
{
return (MFStandardConnection) Connector.open(tProp[j].getUrl(connections[i]));
}
catch (Exception e)
{
form.append("Main Exception : "+e.toString());
}
}
}
}
}
return null;
}
'''''''''''''''''''''''''''Closed Here''''''''''''''''''''''''''''''''''''''
''''''''''''''''''''''''for target detection''''''''''''''''''''
public void targetDetected (TargetProperties [] tProp)
{
conn = getMFStandardConnection(tProp);
if(conn == null)
{
try
{
conn.close();
}
catch(Exception exp){}
}
else if(conn!=null)
{
form.append("Connection Found.");
String usid = readData(12).trim().substring(0,8);
String vhno = readData(13).trim();
String expdt = readData(26).trim();
tf_cardid.setString(usid);
tf_expdate.setString(expdt);
tf_vhno.setString(vhno);
}
try
{
conn.close();
form.append("conection closed");
}
catch (IOException e){form.append("Get IO Exception : "+e.toString());}
}
''''''''''''''''''''''''''Close Here'''''''''''''''''''''
''''''''''''''''''''''for card read'''''''''''''''''''''''''''
public String readData(int b)
{
MFBlock block = conn.getBlock(b);
byte[] k = {(byte)0xff,(byte)0xff,(byte)0xff,(byte)0xff,(byte)0xff,(byte)0xff};
MFKey.KeyA key = new MFKey.KeyA(k);
String str="";
byte[] counterBytes = new byte[100];
try
{
block.read(key, counterBytes, 0, 0, 12);
str=new String(counterBytes);
}
catch (Exception e){form.append("read Exception : "+e.toString());}
return str;
}
'''''''''''''''''''''''''''close here'''''''''''''''''''''''''''''''