如何在一个片段上启动Zxing? [英] how to start Zxing on a Fragment?
问题描述
我有一个活动,其中包含两个片段,我想在其中一个片段上运行ZXING扫描器,
i have an activity that holds Two Fragments, i want to run ZXING scanner on one of the fragments,
目前,我是在其他类似这样的活动上进行此操作
currently i do this on another activity like this >
new IntentIntegrator(this).initiateScan(); // opens up Scan intent > ZXING
我该怎么做,但要打开对片段的扫描?
how do i do that line but to open up the scan on a fragment ?
我也可以在这样的接收器上获得ZXING结果>
Also i get the ZXING results on a reciever like this >
//results when activity enters a callback sent out to another activity
public void onActivityResult(int requestCode, int resultCode, Intent intent) {
我将如何在要运行Zxing的Fragment上获取它们?
how will i get them on my Fragment that i'm going to run Zxing on ?
THNX
推荐答案
我该怎么做,但要打开对片段的扫描?
how do i do that line but to open up the scan on a fragment ?
使用getActivity()在 IntentIntegrator
中以以下方式传递上下文:
Use getActivity() to pass Context in IntentIntegrator
as:
new IntentIntegrator(getActivity()).initiateScan();
我将如何在要运行Zxing的Fragment上获取它们?
how will i get them on my Fragment that i'm going to run Zxing on ?
在两个 super.onActivityResult(requestCode,resultCode,data);
行中的Fragment容器Activity中使用
覆盖 onActivityResult
;在Fragment中,仅覆盖 onActivityResult
方法.
override onActivityResult
in both Fragment container Activity with super.onActivityResult(requestCode, resultCode, data);
line and in Fragment just override onActivityResult
method.
这篇关于如何在一个片段上启动Zxing?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!