I've already tried several things and now I've put all actions into one receiver:
<receiver android:name=".ReceiverClass">
<intent-filter android:priority="1000">
<action android:name="android.intent.action.PACKAGE_REPLACED" />
<action android:name="android.intent.action.MY_PACKAGE_REPLACED" />
<action android:name="android.intent.action.PACKAGE_INSTALL"/>
<action android:name="android.intent.action.PACKAGE_ADDED"/>
<action android:name="android.intent.action.PACKAGE_REMOVED"/>
<data android:scheme="package"/>
</intent-filter>
</receiver>
This is my Receiver class
public class ReceiverClass extends BroadcastReceiver {
@Override
public void onReceive(Context context, Intent intent) {
if (Intent.ACTION_PACKAGE_REPLACED.equals(intent.getAction())) {
Toast.makeText(context, "1", Toast.LENGTH_LONG).show();
}
if (Intent.ACTION_MY_PACKAGE_REPLACED.equals(intent.getAction())) {
Toast.makeText(context, "2", Toast.LENGTH_LONG).show();
System.out.println("test");
}
if (Intent.ACTION_PACKAGE_REPLACED.equals(intent.getAction())) {
Toast.makeText(context, "3", Toast.LENGTH_LONG).show();
System.out.println("test");
}
if (Intent.ACTION_PACKAGE_INSTALL.equals(intent.getAction())) {
Toast.makeText(context, "4", Toast.LENGTH_LONG).show();
System.out.println("test");
}
if (Intent.ACTION_PACKAGE_ADDED.equals(intent.getAction())) {
Toast.makeText(context, "5", Toast.LENGTH_LONG).show();
System.out.println("test");
}
if (Intent.ACTION_PACKAGE_REPLACED.equals(intent.getAction())) {
Toast.makeText(context, "6", Toast.LENGTH_LONG).show();
System.out.println("test");
}
}
}
None of the Toasts get displayed, when I manuall install a new signed APK. Is there something I am missing as the only really replied posts are from 2015 or even earlier. Time flies.
ACTION_PACAKGE_INSTALL
has never been used, according to the documentation.
ACTION_MY_PACKAGE_REPLACED
is only broadcast to you if your own app is being upgraded. You will not receive it for changes in other apps.
The other three you cannot register for in the manifest on Android 8.0+, as implicit broadcasts are banned and those actions are not on the whitelist.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With