How to integrate Zxing Barcode Scanner without installing the actual zxing app (cannot resolve symbol: .android.CaptureActivity)?

前端 未结 8 1529
我寻月下人不归
我寻月下人不归 2020-12-07 10:04

I want to integrate zxing scanner into my app without needed of external application (zxing scanner from play store). This is my code

Button scan = (Button)         


        
8条回答
  •  失恋的感觉
    2020-12-07 10:34

    Elaborating stackex's answer.... Create an activity with any name.

    public class CaptureActivityAnyOrientation extends CaptureActivity {
    }
    

    In manifest define the desired orientation or leave like below to work in both landscape and portait.

    
    

    Finally use the activity created as setCaptureActivity.

    IntentIntegrator.forSupportFragment(fragment)
                        .setCaptureActivity(CaptureActivityAnyOrientation.class)
                        .setOrientationLocked(false)
                        .setBeepEnabled(true)
                        .addExtra("PROMPT_MESSAGE", "Scan QR Code")
                        .initiateScan(IntentIntegrator.QR_CODE_TYPES);
    

    Hope this helps.

提交回复
热议问题