How to register for ACTION_PACKAGE_ADDED and ACTION_PACKAGE_REMOVED on Android Oreo?

From the docs:

Apps that target Android 8.0 or higher can no longer register broadcast receivers for implicit broadcasts in their manifest. An implicit broadcast is a broadcast that does not target that app specifically. For example, ACTION_PACKAGE_REPLACED is an implicit broadcast, since it is sent to all registered listeners, letting them know that some package on the device was replaced.

This says that you cannot register these intents in your manifest. You can still register them programmatically to receive them when your app is running.

You might also try ACTION_PACKAGE_FULLY_REMOVED, which is one of the exceptions that you can still listen to by registering it in the manifest. There is no such 'alternative' for when a package is added.

As CW noted, you could also periodically check for changes in the roster of installed apps.

You can also use polling, setting up a JobScheduler job to check every so often, asking PackageManager for what has changed in the roster of installed apps via getChangedPackages().