In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-09-15 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/02 Report--
This article mainly introduces Android how to achieve desktop shortcuts, has a certain reference value, interested friends can refer to, I hope you can learn a lot after reading this article, the following let Xiaobian take you to understand.
Android shortcut
Mode of use
ShortcutUtils.getInstance () .addShortcut (this, MainActivity2.class, liveBundle, "live_Id", "watching Live" "watch live", R.drawable.live) .addShortcut (this, MainActivity2.class, vodBundle, "vod_Id" "watch playback", "watch playback", R.drawable.vod) .build ()
Add permission
ShortcutUtils utility class (used directly)
/ * Android Shortcut tool Class * Build.VERSION.SDK_INT > = 25 * API25 and above are available * setShortLabel setting short title * setLongLabel setting long title * setIcon setting icon * setIntent setting Intent * @ author renquan * @ date 27 December 2021 * / public class ShortcutUtils {private static ShortcutUtils shortcutUtils; private List shortcutInfos; private Context mContext Public static ShortcutUtils getInstance () {if (shortcutUtils = = null) {synchronized (ShortcutUtils.class) {if (shortcutUtils = = null) {shortcutUtils = new ShortcutUtils ();} return shortcutUtils;} private ShortcutUtils () {shortcutInfos = new ArrayList () } / * set Class object * all parameters cannot be empty * @ param context * @ param cls * @ param bundle * @ param shortcutId * @ param shortLabel * @ param longLabel * @ return * / public ShortcutUtils addShortcut (Context context, Class cls, Bundle bundle, String shortcutId, String shortLabel, String longLabel @ DrawableRes int resId) {if (shortcutUtils! = null & & shortcutInfos! = null) {if (Build.VERSION.SDK_INT > = 25) {mContext = context Intent intent = new Intent (context, cls); intent.putExtra ("shortcutArgument", bundle); intent.setAction (Intent.ACTION_VIEW); intent.addFlags (Intent.FLAG_ACTIVITY_NEW_TASK) ShortcutInfo shortcutInfo = new ShortcutInfo.Builder (context, shortcutId) .setShortLabel (shortLabel) .setLongLabel (longLabel) .setIcon (Icon.createWithResource (context, resId)) .setIntent (intent) .build (); shortcutInfos.add (shortcutInfo) }} return shortcutUtils } / * set Intent object * all parameters cannot be empty * @ param context * @ param intent * @ param shortcutId * @ param shortLabel * @ param longLabel * @ param resId * @ return * / public ShortcutUtils addShortcut (Context context, Intent intent, String shortcutId, String shortLabel, String longLabel @ DrawableRes int resId) {if (Build.VERSION.SDK_INT > = 25) {mContext = context If (shortcutUtils! = null & & shortcutInfos! = null) {ShortcutInfo shortcutInfo = new ShortcutInfo.Builder (context, shortcutId) .setShortLabel (shortLabel) .setLongLabel (longLabel) .setIcon (Icon.createWithResource (context) ResId) .setIntent (intent) .build () ShortcutInfos.add (shortcutInfo);}} return shortcutUtils;} / * build Shortcuts * / public void build () {if (shortcutInfos! = null & & shortcutInfos.size () > 0 & & mContext! = null) {ShortcutManager systemService = mContext.getSystemService (ShortcutManager.class); systemService.setDynamicShortcuts (shortcutInfos) } Thank you for reading this article carefully. I hope the article "how to achieve Desktop Shortcut" shared by the editor will be helpful to everyone. At the same time, I also hope that you will support and pay attention to the industry information channel. More related knowledge is waiting for you to learn!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
The market share of Chrome browser on the desktop has exceeded 70%, and users are complaining about
The world's first 2nm mobile chip: Samsung Exynos 2600 is ready for mass production.According to a r
A US federal judge has ruled that Google can keep its Chrome browser, but it will be prohibited from
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
About us Contact us Product review car news thenatureplanet
More Form oMedia: AutoTimes. Bestcoffee. SL News. Jarebook. Coffee Hunters. Sundaily. Modezone. NNB. Coffee. Game News. FrontStreet. GGAMEN
© 2024 shulou.com SLNews company. All rights reserved.