Often, apps have a "Share" button. When using other apps on my device which have the "Share" button (e.g. web browser, news apps, etc), when you tap this button it shows you a list of apps to share the URL with.
So, for example, I can be in Chrome, navigate to a page, tap Share, and from this I can select my email app to share the URL.
Any advice on how that can be implemented in Maui? I.e. I want my app to appear in the Share dialog.
Thanks
P.S. apologies for the poor wording before ;)
Here's what works for me in Android platform. I can launch my app one of two ways:
Here's the Android Intent Filter code.
using Android.App;
using Android.Content;
using Android.OS;
using url_interceptor;
namespace url_interceptor.Platforms.Android
{
[Activity(Label = "UrlInterceptorActivity", Exported =true)]
[IntentFilter(
new[] { Intent.ActionView },
Categories = new[]
{
Intent.CategoryDefault,
Intent.CategoryBrowsable
},
DataSchemes = new[]
{
"net.ivsoftware.demo"
})]
[IntentFilter(
new[]
{ Intent.ActionSend },
Categories = new[]
{
Intent.CategoryDefault,
},
DataMimeType = "text/plain"
)]
public class UrlInterceptorActivity : Activity
{
protected override void OnCreate(Bundle savedInstanceState)
{
base.OnCreate(savedInstanceState);
Intent intent = Intent;
var uri = intent.Data;
StartMainActivity();
Task
.Delay(TimeSpan.FromSeconds(0.5))
.GetAwaiter()
.OnCompleted(() =>
{
switch (this.Intent.Action)
{
case Intent.ActionView:
if (intent.Action == Intent.ActionView)
{
var uri = intent.Data;
App.Current.MainPage.DisplayAlert("Interceptor", "Deep Link Button", "OK");
}
break;
case Intent.ActionSend:
var link = intent.GetStringExtra(Intent.ExtraText);
App.Current.MainPage.DisplayAlert("Interceptor", $"Shared Link: '{link}'", "OK");
break;
}
});
Finish();
}
private void StartMainActivity()
{
Intent mainActivityIntent = new Intent(this, typeof(MainActivity));
StartActivity(mainActivityIntent);
}
}
}
iOS has a similar mechanism for intercepting URLs but I haven't tested this particular action.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With