I want to transfer binary data with QR, so I tested the following: I generated random byte array, and convert it to string with ISO-8859-1, which does not lose data while transferring.
byte []buffer = new byte[50];
Random randomGenerator = new Random();
for(int i=0;i<=49;i++){
buffer[i]=(byte) randomGenerator.nextInt(254);
}
Log.i("time1","original: "+Arrays.toString(buffer));
String decoded = null;
try {
decoded = new String(buffer, "ISO-8859-1");
} catch (UnsupportedEncodingException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
Log.i("time1","encoded string:" + decoded);
BitMatrix result=null;
try {
result=qw.encode(decoded, BarcodeFormat.QR_CODE, 500, 500);
} catch (WriterException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}
But when i receive the encoded QR, its result is null, which means my input cannot be decoded. Is there any way for me to encode and decode QR in byte mode?
Thank you!