How to force using zxing lib with only my application?

前端 未结 4 1012
抹茶落季
抹茶落季 2020-12-19 20:20

Ok lets say there are 3 different applications which are using zxing lib on the phone. Whenever I want to open zxing with my own application android asks me whether to compl

4条回答
  •  醉梦人生
    2020-12-19 20:33

    Actually you need to remove intent-filter like CommonsWare said, so it must be as follows:

    
    
    

    and instead of calling via external intent you should call zxing like:

    private final static int ACTION_ZXING_SCANNER = 0x0000c0de; //IntentIntegrator.REQUEST_CODE
    private void startZxingScanner() {
        final Intent intent = new Intent(this, com.google.zxing.client.android.CaptureActivity.class);
        intent.setAction(Intents.Scan.ACTION);
        startActivityForResult(intent, ACTION_ZXING_SCANNER);
    }
    

    and then process result in onActivityResult() using request code ACTION_ZXING_SCANNER. The import string if needed:

    import com.google.zxing.client.android.Intents;
    

    note: this works for me and I added zxing project as a lib to my project so here it is - the "zxing lib" :)

提交回复
热议问题