0
我正在使用應用程序在正在開發的應用程序中讀取QR代碼(條形碼)。我的問題是,我不希望條形碼在菜單創建時啓動(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);
}
,並在掃描類,我有以下菜單:
@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);
}
}
但是,在菜單的cration,條形碼應用每次啓動時,即使選擇了不是掃描儀的當前標籤,也會跳過菜單顯示。如何解決這個問題?
謝謝!
我改變了在onStart方法的onResume和的工作。這是一個好主意還是壞主意? – Derbie 2013-04-04 09:08:47