I wanted to find the upgrade of my app. So i have been using this code to find it PACKAGE_REPLACED, but suddenly i could not receive event for package replacing of my app.
And i changed to MY_PACKAGE_REPLACED. still same issue.
Analysed some stack over flow questions. no luck. tried all of the answer.
My target sdk version is 30:
Manifest Code:
<receiver android:name=".Receiver" android:enabled="true" android:debuggable="true" android:exported="true"
tools:ignore="HardcodedDebugMode">
<intent-filter>
<action android:name="android.intent.action.PACKAGE_REPLACED" />
</intent-filter>
<intent-filter>
<action android:name="android.intent.action.BOOT_COMPLETED" />
</intent-filter>
<intent-filter>
<action android:name="android.net.conn.CONNECTIVITY_CHANGE" />
</intent-filter>
</receiver>
Receiver code
@Override
public void onReceive(Context context, Intent intent) {
String action = intent.getAction();
Log.d(TAG, "action = " + action);
if (Intent.ACTION_BOOT_COMPLETED.equals(action)) {
Log.d(TAG, "BOOT COMPLETED, Ping start...");
} else if (Intent.ACTION_PACKAGE_REPLACED.equals(action)) {
Log.d(TAG, "PACKAGE REPLACED, upgrade ping...");
} else {
//default action is network changed
Log.d(TAG, "network status changed...");
}
}