Search code examples
androidxamarin.formsxamarin.androidlauncherandroid-11

Xamarin Launcher.CanOpenAsync() not returning correct value on Android 11


I have two Xamarin apps that I manage. I am trying to open App2 by clicking a button in App1. I have the following code which works on lower versions of Android. On Android 11 however, this code always returns false. Is additional configuration needed for Android 11?

//The uri here is correct and App2 is installed on the Android 11 device
var canOpenApp2 = await Launcher.CanOpenAsync("app2url://deep-link"); 
return canOpenApp2

On Android 8, 9, and 10 canOpenApp2 returns true but on Android 11 the return value is false. Thoughts?


Solution

  • In Android 11 developers must specify the apps they plan to open or "deep link" into in the Android Manifest. Adding the following to the AndroidManifest resolved the issue:

    <queries>
            <package android:name="app2url://deep-link" />
    </queries>
    

    See this post for more information: Managing Package Visibility