how to start Zxing on a Fragment?

后端 未结 5 661
无人共我
无人共我 2021-02-06 15:30

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 >

         


        
5条回答
  •  北恋
    北恋 (楼主)
    2021-02-06 16:33

    how do i do that line but to open up the scan on a fragment ?

    Use getActivity() to pass Context in IntentIntegrator as:

    new IntentIntegrator(getActivity()).initiateScan(); 
    

    how will i get them on my Fragment that i'm going to run Zxing on ?

    override onActivityResult in both Fragment container Activity with super.onActivityResult(requestCode, resultCode, data); line and in Fragment just override onActivityResult method.

提交回复
热议问题