1

I'm using ZXing, the barcode scanning library. It's also an app that you can download and install independantly, but I am currently using it as a library to integrate into my app. I want to be able to invoke that library and bring up one of its activities. In order to do so I use 'intent' and 'startactivityforresult' in which I declare the package name 'com.google.zxing.client.android'. In doing so it prompts me with the ability to choose between the installed stand alone barcode app, or my app. I need to circumvent that dialog so that it will just choose my app by default. It's interesting because I believe the reason I can't use normal methods to bypass that 'complete action using' dialog is that the app has the same package name as the library that I'm using. Any assistance would be appreciated. If you require code or pictures then I'll post it but I believe that I've provided enough information.

D Mw
  • 21
  • 5

1 Answers1

1

If you're able to define the calling Intent contents it's easy - just give it custom string pointing to your activity.

Intent intent = new Intent("com.yourapp.package.SOME_ACTION")

And register the action in manifest:

<activity android:name=".package.CalledActivity">
    <intent-filter>
        <action android:name="com.yourapp.package.SOME_ACTION"/>
    </intent-filter>
</activity>

Your activity may extend library's activity to do the job.

If you're not able to influence sent Intent me thinks it's not possible to circumvent chooser dialog, except a) uninstalling apps which handle com.google.zxing.client.android so there's only one left b) user chooses your app to handle Intent "Always", not "Just Once".

InTwoMinds
  • 655
  • 4
  • 9
  • 1
    Thank you, it wasn't the exact solution but it helped lead me to it. I stupidly wasn't thinking about intent filters so when I tried previous ideas they didn't work. My solution was to rename the package of the library and direct the intent filter at that. It didn't work previously because I was directing the activity at it instead. I.e. when I should have been changing the to what my new package name was – D Mw Jan 12 '16 at 10:59