所以我需要获取结果,当我使用登录按钮扫描时,当我使用注销按钮扫描时,另一个结果。这是因为他们应该更新2个不同的表(signIn和sigOut表)
try {
Button scanner = (Button)findViewById(R.id.signInBtn);
scanner.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
Intent intent = new Intent("com.google.zxing.client.android.SCAN");
intent.putExtra("SCAN_MODE", "QR_CODE_MODE");
startActivityForResult(intent, 0);
}
});
Button scanner2 = (Button)findViewById(R.id.signoutBtn);
scanner2.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
Intent intent1 = new Intent("com.google.zxing.client.android.SCAN");
intent1.putExtra("SCAN_MODE", "QR_CODE_MODE");
startActivityForResult(intent1, 0);
}
});
} catch (ActivityNotFoundException anfe) {
Log.e("onCreate", "Scanner Not Found", anfe);
getClass();
}
list= (Button) findViewById(R.id.lookup_btn);
list.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v){
Intent intent = new Intent(MainActivity.this,SearchActivity.class);
startActivity(intent);
finish();
}
});
}
答案 0 :(得分:0)
只需在代码中更改这两行
即可 startActivityForResult(intent, 0);
和
startActivityForResult(intent1, 1);
并根据结果
对onActivityResult进行更改