Search code examples
androidflutterandroid-manifestredirect-uri

Why is Android giving my Flutter app twice as options to handle the redirect URI when I only specified one entry for it in AndroidManifest.xml?


I am running my app in release mode.

Here is my AndroidManfiest.xml:

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.gmail.joelc0193.st_james_park_app">
    <application
        android:label="St James Park"
        android:icon="@mipmap/ic_launcher">
        <activity
            android:name=".MainActivity"
            android:exported="true"
            android:launchMode="singleTop"
            android:theme="@style/LaunchTheme"
            android:configChanges="orientation|keyboardHidden|keyboard|screenSize|smallestScreenSize|locale|layoutDirection|fontScale|screenLayout|density|uiMode"
            android:hardwareAccelerated="true"
            android:windowSoftInputMode="adjustResize">
            <!-- Specifies an Android theme to apply to this Activity as soon as
                 the Android process has started. This theme is visible to the user
                 while the Flutter UI initializes. After that, this theme continues
                 to determine the Window background behind the Flutter UI. -->
            <meta-data
                android:name="io.flutter.embedding.android.NormalTheme"
                android:resource="@style/NormalTheme"
            />
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
        <activity
            android:name=".SpotifyCallbackActivity"
            android:exported="true">
            <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="${appAuthRedirectScheme}" android:host="spotify-callback" />
            </intent-filter>
        </activity>

        <!-- Don't delete the meta-data below.
             This is used by the Flutter tool to generate GeneratedPluginRegistrant.java -->
        <meta-data
            android:name="flutterEmbedding"
            android:value="2" />
    </application>
    <uses-permission android:name="android.permission.INTERNET" />
    <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
    <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
</manifest>

The redirect URI in question is spotify-callback.

When I delete the entry in my AndroidManifest.xml file and authenticate with Spotify, my app does not get the token back. When I put the entry back, Android gives my app twice as options. Why is this?

Also, out of the two options presented, one of them doesn't take me back to the app and just leaves me in the browser, and the other one works.

I was expecting the browser to just close and for Android to just continue with my app without being presented with my app twice as options to continue with and being made to choose one.

Edit: (Adding video) Screen recording of undesired behavior


Solution

  • The issue was this line:

    android:exported="true">
    

    It should have been set to "false"