我正在编写android应用程序,并且我的客户端需要在其中使用条形码扫描仪。他们真的很具体,所以他们想要的布局是这样的:



如果找到一个二维码-它会自动跳到另一个窗口。如果手动按下-要求您手动键入并继续执行该应用程序的其余部分。

因此,基本上我可以将zxing代码嵌入到我的应用程序中并将其添加到活动中,但是我不希望这样做,而是希望将其作为单独的应用程序使用。

目前,我有一个单独的活动,如下所示:

IntentIntegrator integrator = new IntentIntegrator(this);
integrator.initiateScan();


我也试过这个:

IntentIntegrator intentIntegrator = new IntentIntegrator(this);
Intent i = intentIntegrator.initiateCustomScan();

LocalActivityManager mgr = getLocalActivityManager();

Window w = mgr.startActivity("unique_per_activity_string", i);
View wd = w != null ? w.getDecorView() : null;

if(wd != null) {
  scanButton.addView(wd);
}


但是然后我得到了java.lang.SecurityException:

03-19 12:22:55.890: E/AndroidRuntime(29394): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.menucard.barcode.scan/com.barcode.scan.ScanActivity}: java.lang.SecurityException: Requesting code from com.google.zxing.client.android (with uid 10139) to be run in process com.menucard.barcode.scan (with uid 10169)


也许有人对如何在我的活动中添加单独的应用程序有所了解?还是其他方法可以做到这一点?

最佳答案

不幸的是,您不能通过Intent将外部应用程序嵌入到另一个应用程序中。对于初学者来说,这里的外部应用需要占据整个屏幕,并且处于横向模式。

您应该编写自己的应用程序,但是可以在您的应用程序中重复使用条形码扫描仪的某些部分,这样就不会完全从头开始。请不要复制AndroidManifest.xml文件。考虑到不同的UI,我认为它也不会与Barcode Scanner混淆。剩下要做的就是确保您遵循Apache许可的条款(简单)。

10-05 20:22