Launcher.LaunchUriAsync() not working on Android
Closed this issue · 3 comments
Describe the bug
As the title says, the method LaunchUriAsync() on Android is not working. I found reference of the same problem here. When calling the methods and passing a valid URI the Android application simply does nothing, no crash, error, log or anything. On windows it works without any problem, but on Android it does not.
To Reproduce
I'll now provide the code I'm usign and the way I fixed this:
public async Task OpenLinkInteractionHandler(InteractionContext<string, Unit> context)
{
var launcher = TopLevel.GetTopLevel(this).Launcher;
Uri uri = new Uri(context.Input);
// We do not wait for the operation to be completed, as we do not verify if it actually has been completed
launcher.LaunchUriAsync(uri);
context.SetOutput(Unit.Default);
}
This code is inside a ReactiveUI Interaction, because I need a way to launch the URI from a ViewModel's command, but I don't think the problem is here. For context, in the ViewModel I have a OpenLinkInteraction, I then call the Handle() method in an async Task method, because if I don't await for the interaction handler said handler seems to not get executed.
Anyway, to fix the problem I tried looking at the documentation, without results, then I looked on the MAUI docs to open a link, added the following lines of code to the manifest.xml and everything worked.
<queries>
<intent>
<action android:name="android.intent.action.VIEW" />
<data android:scheme="http"/>
</intent>
<intent>
<action android:name="android.intent.action.VIEW" />
<data android:scheme="https"/>
</intent>
</queries>
Expected behavior
I expected to have the link start on Android, or at least open the popup to select the browser, but without the line I provided above it does not work.
All of this said, I may be mistaken, and I may did something wrong, if so please feel free to let me know, but since I did not find any evidence I did something wrong, I'm creating this new issue.
Avalonia version
11.1.0
OS
Android
Additional context
No response
Please try 11.2.2 build or nightly. There have been fixes related to launcher on android.
I can confirm it works well in latest release version.
Yes, I updated the packages and now it works! Sorry for the inconvinience.