I want to know if it's possible in android to start application using QR Code reader. The things that I want to achieve is :
I create QR Code and after scanning it with QR Code reader I need to start my application with some params, maybe it will looks something like this : myApp://org.hardartcore.myApp?myParams or maybe something similar to this, not really sure.
Is there anyway to achieve this and to get the param which is build in the qr code with the intent for launching the application.
Create QR CODE with this text : myApp://extraString
and read it with any qr code reader. Or even you can integrate your own qr code reader using Zxing
's open source. And you can get the extraString
as @Sean Owen mentioned using getIntent().getDataString()
. And don't forget to add this in your manifest file :
<intent-filter>
<action android:name="android.intent.action.VIEW"/>
<category android:name="android.intent.category.DEFAULT"/>
<category android:name="android.intent.category.BROWSABLE"/>
<data android:scheme="myApp"/>
</intent-filter>
That should work.
Yes. In AndroidManifest.xml
, in your <activity>
, declare that the app responds to this URL:
<intent-filter>
<action android:name="android.intent.action.VIEW"/>
<category android:name="android.intent.category.DEFAULT"/>
<category android:name="android.intent.category.BROWSABLE"/>
<data android:scheme="myApp" android:host="org.hardartcore.myApp" android:path="/"/>
</intent-filter>
(I think you may have to end with a "/" before your "?" for this to work.)
Then anything that uses the platform to resolve a URL will open your app. Hyperlinks in a web browser will work.
The URL itself can be retrieved with getIntent().getDataString()
. You can parse it as an android.net.Uri
as you like.
Look at CaptureActivity
in ZXing for an example of how it does this.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With