title: On update app broadcast receiver is getting called two times in Android
body: <p>Hello I am working on app where I'm capturing instal/uninstall event of any app. For this I'm using <code>BroadcastReceiver</code>, everything is working fine but I found that whenever any app get updated then this same <code>BroadcastReceiver</code> is called two times.</p>
  
  <p>First is uninstall then Install event. I don't want to capture update event of any app. How I can control this.</p>
  
  <pre><code>&lt;receiver android:name=".ReceiverInstallApp" &gt;
      &lt;intent-filter android:priority="2147483647" &gt;
          &lt;action android:name="android.intent.action.PACKAGE_ADDED" /&gt;
          &lt;action android:name="android.intent.action.PACKAGE_INSTALL" /&gt;
          &lt;action android:name="android.intent.action.PACKAGE_REMOVED" /&gt;
  
          &lt;data android:scheme="package" /&gt;
      &lt;/intent-filter&gt;
  &lt;/receiver&gt;
  </code></pre>
  
  <p>ReceiverInstallApp.java</p>
  
  <pre><code>private final String packageAdded = "android.intent.action.PACKAGE_ADDED";
  private final String packageInstalled = "android.intent.action.PACKAGE_INSTALL";
  private final String packageUninstalled = "android.intent.action.PACKAGE_REMOVED";
  
  public void onReceive(Context context, Intent intent) {
      this.context = context;
      Uri uri = intent.getData();
      // this will be the name of the package
      pkgName = uri != null ? uri.getSchemeSpecificPart() : null;
  
      switch (intent.getAction().toString()) {
  
      case packageInstalled:
          setAppStatusInstall(context, pkgName);
          break;
      case packageAdded:
          setAppStatusInstall(context, pkgName);
          break;
      case packageUninstalled:
          setAppStatusUninstall(context, pkgName);
          break;
      default:
          break;
      }
  
  }
  </code></pre>