我对android有点陌生,此时我在我的 ShoplistActivity 上调用barcodeSCanner,如下所示:
Intent barcode = new Intent(ShopListActivity.this, BarcodeActivity.class);
startActivityForResult(barcode,0);
然后在我的 BarcodeActivity 我有这样的东西:
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
switch (requestCode) {
case IntentIntegrator.REQUEST_CODE: {
if (resultCode != RESULT_CANCELED) {
IntentResult scanResult = IntentIntegrator.parseActivityResult(
requestCode, resultCode, data);
if (scanResult != null) {
try {
setContentView(R.layout.automatico);
editForEAN = (EditText) findViewById(R.id.EditEAN);
txt_EAN = scanResult.getContents();
editForEAN.setText(txt_EAN);
} catch (Exception e) {
Toast.makeText(getBaseContext(), e.getMessage(),
Toast.LENGTH_LONG).show();
}
}
}
}
break;
}
}
现在我的问题是,我想用线程实现一种关闭 BarcodeScanner 的方法,如果它没有在 5 秒内使用,尝试使用 Handler 没有成功。