android-customtabs
android-customtabs copied to clipboard
Support package visibility on API level 30+
Android R introduces a new concept called package visibility which affects how apps can discover other apps (mainly through calls to resolveActivity()
and queryIntentActivities()
.
This library uses the latter, meaning for apps targeting API level 30+ the library stops working.
There are a few possible ways to fix this:
-
Ask developers to add the following code snippet to their manifest:
<intent> <action android:name="android.intent.action.VIEW" /> <category android:name="android.intent.category.BROWSABLE" /> <data android:scheme="https" /> </intent>
I tested this and it works (although I didn't test the case where there is no custom tabs enabled browser on the device).
-
Alternatively ask developers to add the following
queries
tag to their manifest. According to the docs this should work as well, but I didn't test it. -
Declare one of the aforementioned
queries
element in this library's manifest. According to the documentation this should have the same effect as (1), but spares the developers using this library the effort to add the tag manually. -
Additionally or alternatively (the docs are not very clear on this) use the
FLAG_ACTIVITY_REQUIRE_NON_BROWSER
orFFLAG_ACTIVITY_REQUIRE_DEFAULT
intent flag when querying for apps.