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 complete action using app 1 or app 2 or my own app. How do I force it to run only through my app without any dialog? Is there any chance to do it?
EDIT
In Additional to CommonsWare, you can do that if you want to handle barcode result on the
other activity.
step 1: jump to method called handleDecode in Capture Activity. Add these lines after handleDecodeInternally(rawResult, resultHandler, barcode);
Intent intent = new Intent(getIntent().getAction());
intent.putExtra("SCAN_RESULT", rawResult.getText());
setResult(RESULT_OK,intent);
finish();
step 2: Do whatever want to do on the other activity’s onActivityResult event.
PS: Thanks again to CommonsWare.
First, there is no “zxing lib”. You are supposed to use the Barcode Scanner application, tying it into your application at the activity level, ideally using their
IntentIntegratorcode. Here is a sample application demonstrating this. The creators of ZXing specifically do not support or endorse baking the Barcode Scanner source code into another application.However, given your symptoms, I have to assume that you are trying to add the Barcode Scanner source code to your own application.
You presumably have something like this in your manifest on the scanning activity’s element:
You are not Barcode Scanner. Yet, this
<intent-filter>claims that you are Barcode Scanner.You need to remove this
<intent-filter>, modify your copy of the Barcode Scanner source code to not require it, and then start up the scanning activity using the component-basedIntentconstructor (e.g.,new Intent(this, ThisIsYourRevisedScanningActivity.class)).