ZXing 条码扫描仪在 ActivityGroup 内失败
我创建了一个小的 tabActivity 应用程序,并且喜欢运行 zxing 并显示结果,而无需使用 ActivityGroup 更改选项卡。 没有 ActivityGroup 一切正常。
这是我的 ScanActivity 的一些代码。如果我“启用”activityGroup,我将永远不会遇到 onActivityResult...:
class ScanButtonClickListener implements OnClickListener {
@Override
public void onClick(View v) {
IntentIntegrator.initiateScan(BarcodeActivity.this);
}
}
public void onActivityResult(int requestCode, int resultCode, Intent intent) {
IntentResult scanResult =
IntentIntegrator.parseActivityResult(requestCode, resultCode, intent);
Log.v("barcode", scanResult.getContents().toString());
}
以下是清单的一部分:
activity android:name=".barcode.BarcodeActivity"
android:theme="@android:style/Theme.NoTitleBar.Fullscreen"
android:screenOrientation="portrait">
</activity>
<activity android:name=".tabGroups.BarcodeTabGroupActivity"></activity>
和 TabGroupActivity,它现在仅启动 BarcodeActivity:
public class BarcodeTabGroupActivity extends TabGroupActivity {
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
startChildActivity("BarcodeActivity", new Intent(this, BarcodeActivity.class));
}
}
以及过滤后的日志:
08-04 15:59:02.093: DEBUG/DecodeHandler(4477): 在 1 毫秒内找到条形码
08-04 15:59:02.144: DEBUG/CaptureActivityHandler(4477): 解码成功消息
08-04 15:59:03.792: DEBUG/CaptureActivityHandler(4477): 收到返回扫描结果消息
android::CameraHardwareSec::stopPreview() :预览未运行,不执行任何操作
08-04 15:59:03.941:INFO/WindowManager(109):将旋转设置为 0,animFlags=1
08-04 15:59:03.957:INFO/ActivityManager(109):配置已更改:{scale=1.0 imsi=0/0 loc=en_US touch=3 键=1/1/2 nav=1/1 orien=1 布局=34 uiMode=17 seq=72}
我认为这一定是 ActivityManager 的问题。一旦 zxing 结束,它就会返回显示按钮,但没有结果。
有什么建议吗?提前致谢!
i created a little tabActivity application and like to run zxing and display the result without changing the tab using an ActivityGroup.
Everything works fine without the ActivityGroup.
And here's some code of the my ScanActivity. If i "enable" the activityGroup i'll never run into the onActivityResult...:
class ScanButtonClickListener implements OnClickListener {
@Override
public void onClick(View v) {
IntentIntegrator.initiateScan(BarcodeActivity.this);
}
}
public void onActivityResult(int requestCode, int resultCode, Intent intent) {
IntentResult scanResult =
IntentIntegrator.parseActivityResult(requestCode, resultCode, intent);
Log.v("barcode", scanResult.getContents().toString());
}
Here are parts of the manifest:
activity android:name=".barcode.BarcodeActivity"
android:theme="@android:style/Theme.NoTitleBar.Fullscreen"
android:screenOrientation="portrait">
</activity>
<activity android:name=".tabGroups.BarcodeTabGroupActivity"></activity>
and the TabGroupActivity, which only launches the barcodeActivity for now:
public class BarcodeTabGroupActivity extends TabGroupActivity {
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
startChildActivity("BarcodeActivity", new Intent(this, BarcodeActivity.class));
}
}
And a filtered log:
08-04 15:59:02.093: DEBUG/DecodeHandler(4477): Found barcode in 1 ms
08-04 15:59:02.144: DEBUG/CaptureActivityHandler(4477): Got decode succeeded message
08-04 15:59:03.792: DEBUG/CaptureActivityHandler(4477): Got return scan result message
android::CameraHardwareSec::stopPreview() : preview not running, doing nothing
08-04 15:59:03.941: INFO/WindowManager(109): Setting rotation to 0, animFlags=1
08-04 15:59:03.957: INFO/ActivityManager(109): Config changed: { scale=1.0
imsi=0/0 loc=en_US touch=3 keys=1/1/2 nav=1/1 orien=1 layout=34
uiMode=17 seq=72}
I think it must be something with the ActivityManager.. as soon as zxing ends, it returns showing the button and no result.
Any tips? thanks in advanced!!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
好吧,我自己设法解决了这个问题。
对于对我的解决方案感兴趣的每个人,这里是:
我没有启动对子活动“BarcodeActivity”的扫描,而是将其引用到父活动:
现在可以通过父 BarcodeTabGroupActivity 中的 onActivityResult 访问结果:
在此onActivityResult 我现在可以启动下一个 childActivity 来处理扫描结果...不知道这是否是好的做法,但它有效。
我以为我必须使用来完成其他儿童活动
,但随后它击落了所有东西..
Ok, i managed to solve this problem on my own.
For everyone who's interested in my solution, here it is:
Instead of initiate the scan on the child activity "BarcodeActivity", i refered it to the parent activity:
And now it's possible to access the result via onActivityResult within the parent BarcodeTabGroupActivity:
Within this onActivityResult i'm now able to start my next childActivity to process the scan results... don't know if that's good practice, but it works.
I thought i have to finish the other child activity using
but then it shoots down everything..