title: Android : restart application after update - ACTION_PACKAGE_REPLACED
body: <p>My application that is not on Play Store verify on the web If there are a new version and download and start it. After the installation I would like to restart the application and I would use a <code>BroadcastRecevier</code> with <code>ACTION_PACKAGE_REPLACED</code>. This is the code :</p>
  
  <p><strong>Broadcast:</strong></p>
  
  <pre><code>public void onReceive(Context context, Intent intent) {
    if(intent.getAction().equals(Intent.ACTION_PACKAGE_REPLACED)){
      ApplicationInfo app = new ApplicationInfo();
      if(app.packageName.equals("it.android.downloadapk")){
        Intent LaunchIntent = context.getPackageManager().getLaunchIntentForPackage(app.packageName);
        context.startActivity(LaunchIntent);                    
      }
    }
  }
  </code></pre>
  
  <p><strong>Manifest:</strong></p>
  
  <pre><code>&lt;receiver android:name="it.android.downloadapk.Broadcast"&gt;
    &lt;intent-filter&gt;
      &lt;action android:name="android.intent.action.ACTION_PACKAGE_REPLACED"&gt;&lt;/action&gt;
      &lt;data android:scheme="package" android:path="it.android.downloadapk" /&gt; 
    &lt;/intent-filter&gt;
  &lt;/receiver&gt;
  </code></pre>
  
  <p>The problem is that when I install new apk, the Broadcast appears not to start, why ?</p>