Setup
https://assetstore.unity.com/packages/tools/integration/shortcuts-manager-for-android-191767
Here you will learn how to Add, Update, Remove and Pin dynamic shortcuts to your app.
Add Shortcut
public const string OPEN_SCREEN = "screen_to_be_opened";
public void AddProfileShortcut () {
// Instance of UnityPlayerActivity
var activity = ShortcutsManager.Instance.GetCurrentAndroidActivity ();
// The actual Shortcut object
var profileShortcut = new Shortcut (
"user_profile_id", // shortcut id
"Profile", // shortcut short label
"Open profile and update your statistics!", // shortcut long label
"account_box", // icon name
0 // rank / order
);
// Intent object which will be 'executed' when
// the user click on the shortcut
var profileIntent = new Intent ()
// Set intent action.
.SetAction (IntentActions.ACTION_VIEW)
// Set intent class name.
.SetClassName (activity, ShortcutsManager.UNITY_PLAYER_ACTIVITY)
// Set intent flags
.SetFlags (IntentFlags.FLAG_ACTIVITY_SINGLE_TOP)
// Put int extra to the intent in order to be able
// to detect which screen we should open when the user
// clicks the shortcut.
.PutExtra (OPEN_SCREEN, (int) Screens.PROFILE);
// Tell the ShortcutManager to add the shortcut with
// the intent which should be executed when the shortcut
// is clicked.
ShortcutsManager.Instance.AddDynamicShortcut (
profileShortcut,
profileIntent
);
}Update Shortcut
You can update an array of shortcuts together using:
Or update the Shortcut with it's Intent together:
Remove Shortcut
You can remove shortcuts in batch by id too:
If you want to remove all dynamic shortcuts you can just call:
Pin Shortcut
If you want to pin a shortcut you can do it easily by using:
Or by passing a Shortcut object and an Intent:
Last updated
Was this helpful?