title: Run code when application is installed
body: <p>I need to know if it is possible to execute code when an application is installed. I've seen that there is a way to run when it starts only for the first time. But I need to run a code when it installs.</p>
  
  <p>I have an application that we develop and we go to another store (IBM Store), when an application is downloaded from the Play Store creates an icon in the "desktop" of the phone. From the IBM Store this does not happen, I had to do it from the code</p>
  
  <pre><code>Intent shortcutIntent = new Intent(getApplicationContext(), MainActivity.class);
  shortcutIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
  shortcutIntent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
  
  Intent addIntent = new Intent();
  addIntent.putExtra(Intent.EXTRA_SHORTCUT_INTENT, shortcutIntent);
  addIntent.putExtra(Intent.EXTRA_SHORTCUT_NAME, "Movistar Click");
  addIntent.setAction("com.android.launcher.action.UNINSTALL_SHORTCUT");
  getApplicationContext().sendBroadcast(addIntent);
  
  addIntent.putExtra(Intent.EXTRA_SHORTCUT_ICON_RESOURCE, Intent.ShortcutIconResource.fromContext(getApplicationContext(), R.mipmap.icon));
  addIntent.setAction("com.android.launcher.action.INSTALL_SHORTCUT");
  getApplicationContext().sendBroadcast(addIntent);
  </code></pre>
  
  <p>However this code is executed when the application opens, not when it is installed.</p>
  
  <blockquote>
    <p>Is there any way to run code when the application is installed?</p>
  </blockquote>