Raise IAvaloniaActivity.Activated on new intent (#20564)

Co-authored-by: Emmanuel Hansen <emmausssss@gmail.com>
This commit is contained in:
Daniel Lerch
2026-02-02 15:15:27 +01:00
committed by GitHub
parent 5483217944
commit 0715676f22
@@ -119,22 +119,14 @@ public class AvaloniaActivity : AppCompatActivity, IAvaloniaActivity
activatableLifetime.CurrentIntendActivity = this;
}
if (Intent?.Data is { } androidUri
&& androidUri.IsAbsolute
&& Uri.TryCreate(androidUri.ToString(), UriKind.Absolute, out var uri))
{
if (uri.Scheme == Uri.UriSchemeFile)
{
if (AndroidStorageItem.CreateItem(this, androidUri) is { } item)
{
_onActivated?.Invoke(this, new FileActivatedEventArgs(new [] { item }));
}
}
else
{
_onActivated?.Invoke(this, new ProtocolActivatedEventArgs(uri));
}
}
HandleIntent(Intent);
}
protected override void OnNewIntent(Intent? intent)
{
base.OnNewIntent(intent);
HandleIntent(intent);
}
protected override void OnStop()
@@ -218,6 +210,26 @@ public class AvaloniaActivity : AppCompatActivity, IAvaloniaActivity
_view = new AvaloniaView(this) { Content = initialContent };
}
private void HandleIntent(Intent? intent)
{
if (intent?.Data is { } androidUri
&& androidUri.IsAbsolute
&& Uri.TryCreate(androidUri.ToString(), UriKind.Absolute, out var uri))
{
if (uri.Scheme == Uri.UriSchemeFile || uri.Scheme == "content")
{
if (AndroidStorageItem.CreateItem(this, androidUri) is { } item)
{
_onActivated?.Invoke(this, new FileActivatedEventArgs(new[] { item }));
}
}
else
{
_onActivated?.Invoke(this, new ProtocolActivatedEventArgs(uri));
}
}
}
public void OnBackInvoked()
{
var eventArgs = new AndroidBackRequestedEventArgs();