# Shortcuts (App Actions)

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.

<figure><img src="https://1168517704-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FKLgWHTlbcMvpwVT7mLBW%2Fuploads%2FuDeMZGoK6BBaApzvXJgi%2Fimage.png?alt=media&#x26;token=803f84fc-c9f7-43f3-9dc1-300f26013471" alt=""><figcaption><p>.NET MAUI App Shortcuts</p></figcaption></figure>

## Sample

{% embed url="<https://github.com/iceteagroup/wisej-hybrid-examples/tree/main/Shortcuts>" %}

## Get started <a href="#get-started" id="get-started"></a>

To access the `AppActions` functionality, the following platform specific setup is required.

### Android

In the *Platforms/Android/MainActivity.cs* file add the following:

```csharp
[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);
	}
}
```

## Determine if actions are supported <a href="#create-actions" id="create-actions"></a>

Not all devices support using app actions. You can check if shortcuts are supported using the following code.

```csharp
var supported = Device.Info.AppActions.IsSupported;
```

## Create actions <a href="#create-actions" id="create-actions"></a>

App actions can be created at any time, but are often created when an app starts.

```csharp
// 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:

```csharp
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`

<pre class="language-csharp"><code class="lang-csharp"><strong>// attach to shortcut event.
</strong><strong>Device.Info.AppActions.AppActionChanged += AppActions_AppActionChanged;
</strong>
// process shortcut click.
private void AppActions_AppActionChanged(object sender, System.EventArgs e)
{
    AlertBox.Show(JsonConvert.SerializeObject(Device.Info.AppActions.Action));
}
</code></pre>

{% hint style="warning" %}
Clicking a shortcut on a Windows desktop app will by default open a new Window. Only the new window will receive the **AppActionChanged** event.
{% endhint %}


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.wisej.com/hybrid/development/shortcuts-app-actions.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
