title: Duplicate pinned shortcut using Shortcut Manager
body: <p>I am trying to create a pinned shortcut on the homescreen of my using ShortcutManager. I am able to create the pinned shortcut using the following code: </p>
  
  <pre><code>Intent i = new Intent();
  i.setAction(Intent.ACTION_VIEW);
  i.setData(Uri.parse("www.google.com"));
  if (ShortcutManagerCompat.isRequestPinShortcutSupported(context)){
      ShortcutInfoCompat shortcutInfo = new ShortcutInfoCompat.Builder(context, "#1")
      .setIntent(i)                
      .setShortLabel("label")                  
      .setIcon(IconCompat.createWithResource(context, R.drawable.ic_launcher))
      .build();
  
     ShortcutManagerCompat.requestPinShortcut(context, shortcutInfo, null);
  }else{
      L.v("Shortcut", "Pinned shortcuts are not supported!");
  }
  </code></pre>
  
  <p>I am facing two issues:</p>
  
  <ol>
  <li>There is no check to handle duplicate shortcuts. Every time I click on the button to create a shortcut, it creates a shortcut every single time and the home screen is getting filled by these shortcuts. Is there any way to check whether the shortcut already exists like:-</li>
  </ol>
  
  <pre><code>Intent i = new Intent();
  i.setAction(Intent.ACTION_VIEW);
  i.setData(Uri.parse("www.google.com"));
  
  Intent installer = new Intent();        installer.putExtra("android.intent.extra.shortcut.INTENT", i);          installer.putExtra("android.intent.extra.shortcut.NAME", "Shortcut name");          installer.putExtra("android.intent.extra.shortcut.ICON_RESOURCE", Intent.ShortcutIconResource.fromContext(getApplicationContext() , R.drawable.ic_launcher));
  installer.putExtra("duplicate", false);
  installer.setAction("com.android.launcher.action.INSTALL_SHORTCUT");
  sendBroadcast(installer);
  </code></pre>
  
  <p>The problem with this piece of code is that it is not working in android 8.0 and above but it handles duplication of shortcut correctly using the following code :-</p>
  
  <pre><code>installer.putExtra("duplicate", false);
  </code></pre>
  
  <p>I want to achieve the same using Shortcut Manager</p>
  
  <ol start="2">
  <li>When a shortcut is created using Shortcut Manager, the icon is duplicated like  </li>
  </ol>
  
  <p><img src="https://i.stack.imgur.com/XeKat.png" alt="duplicate icon"></p>
  
  <p>I have looked at the solution provided here but no luck so far:-</p>
  
  <p><a href="https://stackoverflow.com/questions/53209552/strange-app-icon-duplication-in-pinned-shortcut-android-o">Strange app icon duplication in pinned shortcut (Android O)</a></p>
  
  <p>Any ideas??</p>