Android start application from QR Code with params

Android-Droid picture Android-Droid · Apr 21, 2012 · Viewed 19.6k times · Source

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.

Answer

Android-Droid picture Android-Droid · May 8, 2012

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"/>

That should work.