Created
March 28, 2018 10:16
-
-
Save donrokzon/3299a0e71f2e4d445bfe93208b729427 to your computer and use it in GitHub Desktop.
Add shortcuts api below Nougat
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Intent shortcut = new Intent(getActivity(), MainActivity.class); | |
| shortcut.setAction(Intent.ACTION_MAIN); | |
| Intent add = new Intent(); | |
| add.putExtra(Intent.EXTRA_SHORTCUT_INTENT, shortcut); | |
| add.putExtra(Intent.EXTRA_SHORTCUT_NAME, "Your Activity Name"); | |
| add.putExtra(Intent.EXTRA_SHORTCUT_ICON_RESOURCE, Intent.ShortcutIconResource.fromContext(getActivity(), R.drawable.ic_clock)); | |
| add.setAction("com.android.launcher.action.INSTALL_SHORTCUT"); | |
| getActivity().sendBroadcast(add); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment