Search code examples
androidandroid-intentandroid-manifestandroid-deep-link

Redirect to Android App from browser - before publishing app


I followed the directions here on how to get a browser-to-app redirect working, but seemingly no matter what I do, I'm directed to the play store app with an "Item not found."-screen.

I have tried installing the app on the development tablet I'm working with, in the hopes that when I launch the debug app, go to a website and forget about the debug app, I'm directed back to the installed app.

The reason I want to be able to redirect to the app before publishing, is so that I can ensure that the Multi Factor Authentication feature, which uses a separate website via the browser, works as intended. The MFA feature is in part the whole reason for the apps existence in the first place, as it is very much a demonstration of said MFA system.

Is what I'm trying even possible?

Manifest:

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.company.appname">

    <application
        android:allowBackup="true"
        android:icon="@mipmap/ic_launcher"
        android:label="@string/app_name"
        android:roundIcon="@mipmap/ic_launcher_round"
        android:supportsRtl="true"
        android:theme="@style/AppTheme"
        android:usesCleartextTraffic="true">
        <activity
            android:name=".ui.login.LoginActivity"
            android:label="@string/app_name">
        <intent-filter>
                <action android:name="android.intent.action.MAIN" />
                <category android:name="android.intent.category.LAUNCHER" />
                <category android:name="android.intent.category.BROWSABLE" />
                <action android:name="android.intent.action.VIEW" />
                <category android:name="android.intent.category.DEFAULT" />
                <data android:scheme="customscheme"/>
            </intent-filter>
        </activity>
    </application>
    <uses-permission android:name="android.permission.INTERNET" />
</manifest>

Attempted redirect back to the app is:

intent:#Intent;scheme=customscheme;package=company.appname;end

I also noticed a log in logcat:

2019-11-20 10:57:55.828 25127-25233/? E/Volley: [692] bln.a: Unexpected response code 404 for https://android.clients.google.com/fdfe/details?doc=company.appname&nocache_irl=true

Solution

  • With this configuration:

    <intent-filter>
     <action android:name="android.intent.action.VIEW"></action>
     <category android:name="android.intent.category.DEFAULT"></category>
     <category android:name="android.intent.category.BROWSABLE"></category>
     <data
       android:host="my.app.com"
       android:path="launch"
       android:scheme="http">
     </data>
    </intent-filter>
    

    Whenever you hit http://my.app.com/launch, the system will prompt the user if they want to open with the app or with the browser.

    For more information about intents, read this