3

Basically, it's clear to distinguish implicit and explicit intent

Explicit Intents have specified a component (via setComponent(ComponentName) or setClass(Context, Class)), which provides the exact class to be run. Often these will not include any other information, simply being a way for an application to launch various internal activities it has as the user interacts with the application.

Implicit Intents have not specified a component; instead, they must include enough information for the system to determine which of the available components is best to run for that intent.

But I'm confused by Google's introduced on https://developer.android.com/about/versions/oreo/background.html#broadcasts

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. However, ACTION_MY_PACKAGE_REPLACED is not an implicit broadcast, since it is sent only to the app whose package was replaced, no matter how many other apps have registered listeners for that broadcast.

Why ACTION_MY_PACKAGE_REPLACED is not an implicit broadcast?

5
  • 1
    "it is sent only to the app whose package was replaced" - This means that the Intent is created to target the component registered for that broadcast, and it carries the ACTION_MY_PACKAGE_REPLACED action. Explicit Intents can also have actions. Commented Aug 23, 2017 at 9:20
  • Yes, I know explicit Intent can also have actions, my doubt is why ACTION_MY_PACKAGE_REPLACED is considered as explicit. Commented Aug 23, 2017 at 9:27
  • Are you meaning this action is specified target package when sending by system? Commented Aug 23, 2017 at 9:27
  • 1
    An explicit Intent is created to target the component registered for it. Then, that action is added to the explicit Intent. Commented Aug 23, 2017 at 9:30
  • got it, thanks a lot. Commented Aug 23, 2017 at 16:03

2 Answers 2

2

ACTION_MY_PACKAGE_REPLACED is a intent that is broadcasted ONLY to your application, since it is only triggered when YOUR application is replaced. This makes it a explicit Intent and as such is not subject to the limitation to android O.

However ACTION_PACKAGE_REPLACED is sent to every app whenever a package gets replaced, thus it is not specific to your application. This makes is a implicit Intent and is therfore forbidden under android O's new background rules.

Sign up to request clarification or add additional context in comments.

Comments

0

Why ACTION_MY_PACKAGE_REPLACED is not an implicit broadcast?

Because that's how Google wrote the code that sends ACTION_MY_PACKAGE_REPLACED broadcasts. They create an explicit Intent, identifying the specific receiver to receive the broadcast. They also attach the action string, in case the receiver happens to receive multiple broadcasts and needs to distinguish one from another. An explicit Intent is welcome to have an action string. The distinction between implicit and explicit Intents is whether the Intent identifies the component or not.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.