Android app update broadcast

Your intent filter should be like:

<intent-filter>
   <action android:name="android.intent.action.PACKAGE_REPLACED" />
   <data android:scheme="package" />
</intent-filter>

And onReceive method from your BroadcastReceiver should be:

@Override
public void onReceive(Context context, Intent intent) {
    Uri data = intent.getData();
    if (data.toString().equals("package:" + "com.target.package") {
        // action to do
    }
}

According to android docs: Broadcast Action: A new version of your application has been installed over an existing one. This is only sent to the application that was replaced. It does not contain any additional data; to receive it, just use an intent filter for this action.

<intent-filter>
   <action android:name="android.intent.action.MY_PACKAGE_REPLACED" />
   <data android:scheme="package" />
</intent-filter>

And onReceive method from your BroadcastReceiver should be:

@Override
public void onReceive(Context context, Intent intent) {
    // action to do

}

ACTION_PACKAGE_REPLACED is action triggered when an application is being updated According to docs :

A new version of an application package has been installed, replacing an existing version that was previously installed. The data contains the name of the package.

intent.getPackage() returns the package/application this intent was specifically addressed to but it was sent to any interested receiver, therefore, there isn't such package.

Use intent.getData() which returns the updated package as an Uri

Add the below intent filter while registering a broadcast receiver in your Manifest.xml

<intent-filter>
   <action android:name="android.intent.action.PACKAGE_REPLACED" />
   <data android:scheme="package" />
</intent-filter>