• Android 快捷方式


    长按快捷方式

    1. @TargetApi(Build.VERSION_CODES.N_MR1)
    2. private ShortcutInfo createShortcutInfo1() {
    3. return new ShortcutInfo.Builder(this, "99009")
    4. .setShortLabel("909888")
    5. .setLongLabel("909888")
    6. .setIcon(Icon.createWithResource(this, R.drawable.ic_launcher))
    7. .setIntent(new Intent(Intent.ACTION_VIEW, Uri.parse("http://xiaweizi.cn/")))
    8. .build();
    9. }
    10. private void setDynamicShortcuts() {
    11. if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.N_MR1) {
    12. ShortcutManager shortcutManager = getSystemService(ShortcutManager.class);
    13. List<ShortcutInfo> shortcutInfo = new ArrayList<>();
    14. shortcutInfo.add(createShortcutInfo1());
    15. // shortcutInfo.add(createShortcutInfo2());
    16. if (shortcutManager != null) {
    17. shortcutManager.setDynamicShortcuts(shortcutInfo);
    18. }
    19. }
    20. }

    桌面快捷图标

    1. private void createPinnedShortcuts() {
    2. if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.O) {
    3. ShortcutManager shortcutManager = getSystemService(ShortcutManager.class);
    4. if (shortcutManager != null && shortcutManager.isRequestPinShortcutSupported()) {
    5. Intent intent = new Intent(this, TestActivity.class);
    6. intent.setAction(Intent.ACTION_VIEW);
    7. intent.putExtra("key", "fromPinnedShortcut");
    8. ShortcutInfo pinShortcutInfo = new ShortcutInfo.Builder(this, "my-shortcut")
    9. .setShortLabel(("0000"))
    10. .setLongLabel(("0000"))
    11. .setIcon(Icon.createWithResource(this, R.drawable.ic_launcher))
    12. .setIntent(intent)
    13. .build();
    14. Intent pinnedShortcutCallbackIntent = shortcutManager.createShortcutResultIntent(pinShortcutInfo);
    15. PendingIntent successCallback = PendingIntent.getBroadcast(this, 0,
    16. pinnedShortcutCallbackIntent, FLAG_IMMUTABLE);
    17. boolean b = shortcutManager.requestPinShortcut(pinShortcutInfo, successCallback.getIntentSender());
    18. showToast("set pinned shortcuts " + (b ? "success" : "failed") + "!");
    19. }
    20. }
    21. }

    https://cloud.tencent.com/developer/article/1444202

  • 相关阅读:
    React Router6的用法
    【21天学习挑战赛—经典算法】折半查找
    筹备三年,自动驾驶L3标准将至,智驾产业链的关键一跃
    react-redux 的使用
    这可能是最全面的Python入门手册了!
    手写jQuery的封装
    docker安装mysql8
    SSL VPN综合实验
    Unity界面介绍:其它视图
    Android kotlin在实战过程问题总结与开发技巧详解
  • 原文地址:https://blog.csdn.net/xiaoerbuyu1233/article/details/143324501