Share intent option using Shortcut android

后端 未结 2 2053
孤城傲影
孤城傲影 2021-02-10 10:30

By default iOS is providing \"Share appname\" option in the shortcut options,when the app is downloaded from the app store.

Refer the image belo

2条回答
  •  野趣味
    野趣味 (楼主)
    2021-02-10 11:35

    there is two way to create shortcut.

    one: create static shortcuts,In your app's manifest file (AndroidManifest.xml), find an activity whose intent filters are set to the android.intent.action.MAIN action and the android.intent.category.LAUNCHER category. and then add a element to this activity that references the resource file where the app's shortcuts are defined:

    
    
    
      
        
        
      
    
       
    
    

    ...

    two:Create dynamic shortcuts you can use code to do it,The ShortcutManager API allows you to complete the following operations on dynamic shortcuts:

    ShortcutManager shortcutManager = getSystemService(ShortcutManager.class);
    
    ShortcutInfo shortcut = new ShortcutInfo.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();
    
    shortcutManager.setDynamicShortcuts(Arrays.asList(shortcut));
    

    for more information, you can through the official website how to create shortcut in android?

提交回复
热议问题