FLAG_INCLUDE_STOPPED_PACKAGES

微笑、不失礼 提交于 2019-12-12 11:58:57

问题


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


回答1:


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);



回答2:


From the API guide:

Developers Guide

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




回答3:


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.



来源:https://stackoverflow.com/questions/43546453/flag-include-stopped-packages

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!