【问题标题】:Android launcher - browser link redirect shortcutAndroid 启动器 - 浏览器链接重定向快捷方式
【发布时间】:2021-09-05 13:10:38
【问题描述】:

你好!

我想添加一个 Android 启动器快捷方式来打开它的链接。像这样的图像 这个有可能?如果可能的话,我该怎么做?

【问题讨论】:

  • 他们叫App shortcuts
  • 我知道这一点,但不知道如何添加链接快捷方式 XD

标签: android android-studio android-icons android-shortcut android-shortcutmanager


【解决方案1】:

创建动态快捷方式并将其与您的 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);

Reference

【讨论】:

  • 非常感谢!
猜你喜欢
  • 1970-01-01
  • 2021-11-30
  • 1970-01-01
  • 1970-01-01
  • 2018-05-25
  • 2014-01-23
  • 2012-01-20
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多