1

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

Joel Castro
  • 485
  • 6
  • 20
  • please visit this thread: https://stackoverflow.com/questions/18282892/android-webview-onpagefinished-called-twice – Ali Punjabi Jul 14 '23 at 10:07
  • You mean it's showing twice by, first is "Open with St James Park" with options "Just once" and "Always". And the second one is below "Use a different app: "St James Park" "? As can be seen in the attached video – ermekk Jul 14 '23 at 13:22
  • I mean in the video there's no showing twice as I can see. Android works like that, showing a default app that can handle a given URI and other apps(including the default one) that can handle the URI. – ermekk Jul 14 '23 at 13:26

2 Answers2

0

The issue was this line:

android:exported="true">

It should have been set to "false"

Joel Castro
  • 485
  • 6
  • 20
0

This was happening to me. In my case, the problem happened because with flutter_sharing_intent package you are not suposed include the tags in manifest.xml. So, as soon as I removed tags, the problem was solved.