Shortcuts (App Actions)

Sample
Get started
Android
Determine if actions are supported
Create actions
Responding to actions
Last updated

Last updated
[Activity(Theme = "@style/Maui.SplashTheme", MainLauncher = true, LaunchMode = LaunchMode.SingleTop, ConfigurationChanges = ConfigChanges.ScreenSize | ConfigChanges.Orientation | ConfigChanges.UiMode | ConfigChanges.ScreenLayout | ConfigChanges.SmallestScreenSize | ConfigChanges.Density)]
[IntentFilter(new[] { Platform.Intent.ActionAppAction },
Categories = new[] { global::Android.Content.Intent.CategoryDefault })]
public class MainActivity : MauiAppCompatActivity
{
protected override void OnResume()
{
base.OnResume();
Platform.OnResume(this);
}
protected override void OnNewIntent(Android.Content.Intent intent)
{
base.OnNewIntent(intent);
Platform.OnNewIntent(intent);
}
}var supported = Device.Info.AppActions.IsSupported;// Creates and assigns three app actions to the device's shortcuts.
Device.AppActions.Set(new AppAction[]
{
new AppAction("1", "Messages"),
new AppAction("2", "Recent"),
new AppAction("3", "Settings")
});var shortcut = Device.Info.AppActions.Action;// attach to shortcut event.
Device.Info.AppActions.AppActionChanged += AppActions_AppActionChanged;
// process shortcut click.
private void AppActions_AppActionChanged(object sender, System.EventArgs e)
{
AlertBox.Show(JsonConvert.SerializeObject(Device.Info.AppActions.Action));
}