App shortcuts are helpful to users because they allow you, as the app developer, to present them with extra ways of starting your app. For example, if you were developing an email and calendar app, you could present two different app actions, one to open the app directly to the current day of the calendar, and another to open to the email inbox folder.
Sample
Get started
To access the AppActions functionality, the following platform specific setup is required.
Android
In the Platforms/Android/MainActivity.cs file add the following:
Not all devices support using app actions. You can check if shortcuts are supported using the following code.
var supported = Device.Info.AppActions.IsSupported;
Create actions
App actions can be created at any time, but are often created when an app starts.
// 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")
});
Responding to actions
If the application starts up from a "terminated" state with a shortcut click, the shortcut can be found in:
var shortcut = Device.Info.AppActions.Action;
If the application was already running and a shortcut was clicked, the application will fire Device.Info.AppActions.Changed