I have created a minimal version to check this error.
The app declares in its manifest.xml an activity-alias that points to the only activity of the app,
Manifest.xml:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools">
<application
...>
<activity
android:name="com.dev.testingcustomtabshost.IntentDispatcher"
android:configChanges="orientation|keyboard|keyboardHidden|smallestScreenSize" />
<activity-alias
android:name=".EntryPoint"
android:exported="true"
android:label="@string/app_name"
android:targetActivity="com.dev.testingcustomtabshost.IntentDispatcher">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.LAUNCHER" />
<category android:name="android.intent.category.BROWSABLE" />
<category android:name="android.intent.category.APP_BROWSER" />
</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="http" />
<data android:scheme="https" />
</intent-filter>
</activity-alias>
</application>
</manifest>
Now, we set the app as the device’s default browser.
The activity is the minimum expression that allows checking if the app is called with browser links:
IntentDispatcher.kt:
class IntentDispatcher : AppCompatActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
Log.d("BrowserExperiments", "IntentDispatcher onCreate")
Toast.makeText(this, intent.data.toString(), Toast.LENGTH_LONG).show()
}
}
In this scenario, when we try to open links from the classroom app, we find two answers depending on the type of link.
The link type that works:
The link type that works opened in the app:
The link type that not works:
The link type that not works in the app, opened in brave browser:
While testing, I found something very strange. If I add this dependency in gradle:
debugImplementation("com.squareup.leakcanary:leakcanary-android:2.14")
With this dependency in gradle, it DOES work, although only in the debug build variant. However, this dependency has nothing to do with intent management.
I appreciate any ideas, greetings.