I am developing an application in which i am reading the QR code using zxing library. I am calling the zxing library for reading QR CODE as:
public class QRScanner extends CaptureActivity {
TextView tv;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.qrscanner_layout);
}
@Override
public void handleDecode(Result rawResult, Bitmap barcode) {
tv =(TextView) findViewById(R.id.textview_output);
tv.setText(rawResult.getText());
}
Now i want to call new activity from
public void handleDecode(Result rawResult, Bitmap barcode) {
//Want to call new activity using intent and pass result in new activity.
}
And i tried a code as:
public void handleDecode(Result rawResult, Bitmap barcode) {
String result = rawResult.getText();
Intent intent = new Intent(QRScanner.this,Activity2.class);
intent.putExtra("Result", result);
startActivity(intent);
}
But it is not working. As how to test this code on emulator i don’t know.
When i try to run this app on device it terminates. What should i do for that. It is my application need that the result of QR code scanning is required in next activity.
Please suggest me what should i do for this.
Thank you.
Did you declare Activity2 in your manifest? Wrap that getText() in a try-catch …
At least then you’re passing “” if the result is null.