Skip to content

Instantly share code, notes, and snippets.

@fnk0
Last active October 25, 2016 21:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save fnk0/5dd7a58c508480fc2b9f39afdb2cdc1f to your computer and use it in GitHub Desktop.
Save fnk0/5dd7a58c508480fc2b9f39afdb2cdc1f to your computer and use it in GitHub Desktop.
Shortcuts Example
<shortcuts xmlns:android="http://schemas.android.com/apk/res/android">
<shortcut
android:shortcutId="leaderboard"
android:enabled="true"
android:icon="@drawable/ic_leaderboard_primary"
<!-- -->
<!-- Note this needs to be a string resource, it can NOT be a string -->
<!-- If you try to use a literal string here will cause an error -->
android:shortcutShortLabel="@string/leaderboard"
android:shortcutLongLabel="@string/leaderboard">
<intent
android:action="android.intent.action.VIEW"
android:targetPackage="com.myapp"
android:targetClass="com.myapp.ui.leaderboard.LeaderboardActivity" />
<!--
Update: this was pointed to me by Ian Lake.
The category is an optional parameter. The only one defined by the framework os of right now is
conversation. So if your app doesn't uses any messaging features, just leave this omit this tag.
More info at: https://developer.android.com/reference/android/content/pm/ShortcutInfo.html#SHORTCUT_CATEGORY_CONVERSATION
-->
<categories android:name="android.shortcut.conversation" />
</shortcut>
<shortcut
android:shortcutId="profile"
android:enabled="true"
android:icon="@drawable/ic_social_person_primary"
android:shortcutShortLabel="@string/profile"
android:shortcutLongLabel="@string/profile">
<!--
This intent will be added to the backstack of the app
we can specify as many intents as we want.
The last one will be on top and a proper backstack will be created leading to it.
-->
<intent
android:action="android.intent.action.VIEW"
android:targetPackage="com.myapp"
android:targetClass="com.myapp.ui.home.HomeActivity" />
<intent
android:action="android.intent.action.VIEW"
android:targetPackage="com.myapp"
android:targetClass="com.myapp.ui.profile.UserProfileActivity" />
</shortcut>
</shortcuts>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment