Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

FLAG_INCLUDE_STOPPED_PACKAGES

I have just started with android. while going through code on GitHub, for sending a broadcast, I came across

addFlags(Intent.FLAG_INCLUDE_STOPPED_PACKAGES);

I am unable to understand the functionality of the above statement..if someone could help, it would be really nice. Regards

like image 836
vighneshraje Avatar asked Apr 21 '17 15:04

vighneshraje


People also ask

What is Action_view?

ACTION_VIEW is the action on Intent. public static final String ACTION_VIEW. Since: API Level 1 Activity Action: Display the data to the user. This is the most common action performed on data -- it is the generic action you can use on a piece of data to get the most reasonable thing to occur.

What is an intent object?

An Intent object carries information that the Android system uses to determine which component to start (such as the exact component name or component category that should receive the intent), plus information that the recipient component uses in order to properly perform the action (such as the action to take and the ...

What is Flag_activity_clear_task?

flag — FLAG_ACTIVITY_CLEAR_TASK: This clears any existing task that would be associated with the Activity before the Activity is started. This Activity then becomes the new root of the task and old Activities are finished.

What is flag_exclude_stopped_packages?

In 1. case we deliver the notification. In 2. case we don't (should not). Note that the system adds FLAG_EXCLUDE_STOPPED_PACKAGES to all broadcast intents. It does this to prevent broadcasts from background services from inadvertently or unnecessarily launching components of stoppped applications.

When to use a flag when intent is not started?

You would normally use that flag if the application that receives the intent has never been started. Here is an example. Show activity on this post.

When are applications in a stopped state in Salesforce?

Applications are in a stopped state when they are first installed but are not yet launched and when they are manually stopped by the user (in Manage Applications). We do not add the FLAG_INCLUDE_STOPPED_PACKAGES flag since we are not sure why the app has been stopped.

Do pending notifications get delivered when the app is restarted?

However, when app is resumed again all pending notifications are delivered. This happens even when phone is awake and not sleeping. This is not ideal for me as I am trying to develop a calling app.


3 Answers

You would normally use that flag if the application that receives the intent has never been started.

Here is an example.

Intent intent = new Intent("my.action.Intent");
intent.addFlags(Intent.FLAG_INCLUDE_STOPPED_PACKAGES);
sendBroadcast(intent);
like image 124
Newtron Labs Avatar answered Sep 28 '22 01:09

Newtron Labs


When you install an app on your device it is in "stopped" state, so the app component (activities, receivers etc.) will not respond to intents unless you either first time launch the app (to exist "stopped" state ) or add the FLAG_INCLUDE_STOPPED_PACKAGES flag.

like image 27
Ron____ Avatar answered Sep 28 '22 02:09

Ron____


From the API guide:

Developers Guide

"If set, this intent will always match any components in packages that are currently stopped."

like image 42
Burrough Clarke Avatar answered Sep 28 '22 00:09

Burrough Clarke