Search code examples
androidandroid-studioandroid-iconsandroid-shortcutandroid-shortcutmanager

Android launcher - browser link redirect shortcut


Hello!

I want to add an Android launcher shortcut to open a link with it. Something like this images This is possible? And if is possible, how can I make it?

enter images description here


Solution

  • An example of creating a dynamic shortcut and associating it with your app appears in the following code snippet:

    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