【发布时间】:2021-09-05 13:10:38
【问题描述】:
你好!
我想添加一个 Android 启动器快捷方式来打开它的链接。像这样的图像 这个有可能?如果可能的话,我该怎么做?
【问题讨论】:
-
我知道这一点,但不知道如何添加链接快捷方式 XD
标签: android android-studio android-icons android-shortcut android-shortcutmanager
你好!
我想添加一个 Android 启动器快捷方式来打开它的链接。像这样的图像 这个有可能?如果可能的话,我该怎么做?
【问题讨论】:
标签: android android-studio android-icons android-shortcut android-shortcutmanager
创建动态快捷方式并将其与您的 app出现在如下代码sn-p中:
ShortcutInfo shortcut = new ShortcutInfoCompat.Builder(context, "id1")
.setShortLabel("Website")
.setLongLabel("Open the website")
.setIcon(Icon.createWithResource(context, R.drawable.icon_website))
.setIntent(new Intent(Intent.ACTION_VIEW,
Uri.parse("https://www.mysite.example.com/")))
.build();
ShortcutManagerCompat.pushDynamicShortcut(context, shortcut);
【讨论】: