title: How to create shortcuts on Android O, when targetting less than it?
body: <h2>Background</h2>
  
  <p>Android O has various changes of how shortcuts work:</p>
  
  <p><a href="https://developer.android.com/preview/behavior-changes.html#as" rel="nofollow noreferrer">https://developer.android.com/preview/behavior-changes.html#as</a></p>
  
  <h2>The problem</h2>
  
  <p>According to recent changes on Android O, the broadcast intent to create shortcuts is completely ignored :</p>
  
  <p><a href="https://developer.android.com/reference/android/content/Intent.html#ACTION_CREATE_SHORTCUT" rel="nofollow noreferrer">https://developer.android.com/reference/android/content/Intent.html#ACTION_CREATE_SHORTCUT</a>
  <a href="https://developer.android.com/preview/behavior-changes.html#as" rel="nofollow noreferrer">https://developer.android.com/preview/behavior-changes.html#as</a></p>
  
  <blockquote>
    <p>The com.android.launcher.action.INSTALL_SHORTCUT broadcast no longer
    has any effect on your app, because it is now a private, implicit
    broadcast. Instead, you should create an app shortcut by using the
    requestPinShortcut() method from the ShortcutManager class.</p>
  </blockquote>
  
  <p>This means this code, for example, won't work anymore, no matter which app you've made or which launcher the user has:</p>
  
  <pre><code>private void addShortcut(@NonNull final Context context) {
      Intent intent = new Intent().putExtra(Intent.EXTRA_SHORTCUT_INTENT, new Intent(context, MainActivity.class).setAction(Intent.ACTION_MAIN))
              .putExtra(Intent.EXTRA_SHORTCUT_NAME, "HelloWorldShortcut")
              .putExtra(Intent.EXTRA_SHORTCUT_ICON_RESOURCE, ShortcutIconResource.fromContext(context, R.mipmap.ic_launcher))
              .setAction("com.android.launcher.action.INSTALL_SHORTCUT");
      context.sendBroadcast(intent);
  }
  </code></pre>
  
  <p>Currently, even the Play Store itself fails to create shortcuts to apps (at least in the current version: 80795200 ) . It just doesn't do anything, even to Google's launcher.</p>
  
  <h2>The question</h2>
  
  <p>While I'm very against this change of API (and wrote about it <a href="https://issuetracker.google.com/issues/62973732" rel="nofollow noreferrer"><strong>here</strong></a>, <a href="https://issuetracker.google.com/issues/62544695" rel="nofollow noreferrer"><strong>here</strong></a>) and <a href="https://issuetracker.google.com/issues/62544695" rel="nofollow noreferrer"><strong>here</strong></a>, I'd like to know what would it take to still make it work.</p>
  
  <p>I know there is an API for this, using <a href="https://developer.android.com/reference/android/content/pm/ShortcutManager.html#requestPinShortcut(android.content.pm.ShortcutInfo,%20android.content.IntentSender)" rel="nofollow noreferrer"><strong>requestPinShortcut</strong></a>, but this requires the app to target Android O, which means a lot more changes have to be made to make sure the app works there.</p>
  
  <p>My question is:
  Suppose your app targets Android API 25, how do you create shortcuts on Android O ? Is it possible by using reflection of the newer API ? If so, how?</p>