我正在使用应用程序在我正在开发的应用程序中读取 QR 码(条形码)。我的问题是我不希望在创建菜单时启动条形码(A TabActivity)。要清楚:我以这种方式创建菜单
public void createMenu(int current) {
Resources res = getResources(); // Resource object to get Drawables
TabHost tabHost = getTabHost(); // The activity TabHost
TabHost.TabSpec spec; // Resusable TabSpec for each tab
Intent intent;
intent = new Intent().setClass(this, Scan.class);
spec = tabHost.newTabSpec("scanner").setIndicator(null,res.getDrawable(R.drawable.barcode_scan)).setContent(intent);
tabHost.addTab(spec);
// Do the same for the other tabs
intent = new Intent().setClass(this, Research.class);
spec = tabHost.newTabSpec("research").setIndicator(null,
res.getDrawable(R.drawable.system_search))
.setContent(intent);
tabHost.addTab(spec);
}
并且,在 Scan 类中,我有以下内容:
@Override
public void onStart(){
super.onStart();
setContentView(R.layout.scan);
try {
Intent intent = new Intent("com.google.zxing.client.android.SCAN");
intent.putExtra("SCAN_MODE", "QR_CODE_MODE"); // "PRODUCT_MODE for bar codes
startActivityForResult(intent, 0);
} catch (Exception e) {
Uri marketUri = Uri.parse("market://details?id=com.google.zxing.client.android");
Intent marketIntent = new Intent(Intent.ACTION_VIEW,marketUri);
startActivity(marketIntent);
}
}
但是,在菜单创建时,Barcode 应用程序每次都会启动,即使选择不是扫描仪的当前选项卡也会跳过菜单显示。如何解决?
谢谢 !