Search code examples
androidzbar

Android ZBar custom integration


Good day. I'm trying to create tabbed application (via TabHost), tab bar with icons should be available at all time. However one of my activities implements ZBar component. The recommend way of usage is via intent:

Intent intent = new Intent(this, ZBarScannerActivity.class);
startActivityForResult(intent, ZBAR_SCANNER_REQUEST);

But in this case camera preview just fills the whole available surface. How do I run this component in some frame? I suppose I can try to do that via WebView, but I can't figure out how to get scanning result in that case.


Solution

  • A WebView? No, that's a bad idea.

    You can just call tabHost.setContent(intent); and add the intent.

    startActivityForResult() just opens a new Activity window so don't even use that.

    Example:

    tabHost.addTab(tabHost.newTabSpec("tab1").setIndicator("HOME")
    .setContent(new Intent(this,ZBarScannerActivity.class)));