Обновите свой onActivityResult следующим образом.
//method for getting qr code from qr code after scan
public void onActivityResult(int requestCode, int resultCode, Intent intent) {
if (requestCode == 0) {
if (resultCode == RESULT_OK) {
String contents = intent.getStringExtra("SCAN_RESULT");
Toast.makeText(this, contents , Toast.LENGTH_SHORT).show();
// Handle successful scan
} else if (resultCode == RESULT_CANCELED) {
// Handle cancel
Log.d("the result is","not ok");
}
}