I have an Android app with package name like my.test.app
. I want to generate a QR code, which:
- If my app is installed: Open the app
- If not installed yet: Open the app page in PlayStore
Is there a possible way to do this, so that any Android QR scanner can handle the actions described above? I couldn't find an question/answer which realizes both... Thank you!
EDIT - What I did so far I added the following to my "App to open" manifest:
<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:supportsRtl="true"
android:theme="@style/AppTheme"
android:exported="true" >
<activity android:name=".MainActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
<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="my.test.app"/>
</intent-filter>
</activity>
...
</application>
When I generate a QR code with content my.test.app://test
and scan it, the QR reader app shows the correct content, but won't open my app!
2nd EDIT - Tried some URLs
I just tried to set a few other URLs in my Manifest's intent-filter:
<data android:scheme="http" android:host="play.google.com" android:pathPrefix="/store/apps/details?id=my.test.app"/>
- this asks me whether to open the URL in browser or in PlayStore, if I scan the QR code with content
http://play.google.com/store/apps/details?id=my.test.app
- BUT WON'T OPEN MY APP IF INSTALLED!
- this asks me whether to open the URL in browser or in PlayStore, if I scan the QR code with content
2. <data android:scheme="http" android:host="myapp.com" android:pathPrefix="/barcode"/>
- this opens my app when scanning the QR code
http://myapp.com/barcode
! BUT the problem would be, that there's no solution/target address when the app is not installed when scanning! A redirect via HTML site would be possible maybe, but I don't want to use a HTML server for this!