Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

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.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
883 views
Welcome To Ask or Share your Answers For Others

1 Answer

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 IntentIntegrator code. 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:

        <intent-filter >
            <action android:name="com.google.zxing.client.android.SCAN" />

            <category android:name="android.intent.category.DEFAULT" />
        </intent-filter>

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-based Intent constructor (e.g., new Intent(this, ThisIsYourRevisedScanningActivity.class)).


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...