Android installed app, never used, cannot receiver BroadcastReceiver
2013-09-09 14:22
351 查看
官方文档是这么写的:(http://developer.android.com/about/versions/android-3.1.html#launchcontrols)
Launch controls on stopped applications
Starting from Android 3.1, the system's package manager keeps track of applications that are in a stopped state and provides a means of controlling their launch from background processes and other applications.Note that an application's stopped state is not the same as an Activity's stopped state. The system manages those two stopped states separately.
The platform defines two new intent flags that let a sender specify whether the Intent should be allowed to activate components in stopped application.
FLAG_INCLUDE_STOPPED_PACKAGES—
Include intent filters of stopped applications in the list of potential targets to resolve against.
FLAG_EXCLUDE_STOPPED_PACKAGES—
Exclude intent filters of stopped applications from the list of potential targets.
When neither or both of these flags is defined in an intent, the default behavior is to include filters of stopped applications in the list of potential targets.
Note that the system adds
FLAG_EXCLUDE_STOPPED_PACKAGESto
all broadcast intents. It does this to prevent broadcasts from background services from inadvertently or unnecessarily launching components of stoppped applications. A background service or application can override this behavior by adding the
FLAG_INCLUDE_STOPPED_PACKAGESflag
to broadcast intents that should be allowed to activate stopped applications.
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).
解决方案:1、在发广播的时候加上intent.setFlags(Intent.FLAG_INCLUDE_STOPPED_PACKAGES)
2、把apk放在/system/app/下
相关文章推荐
- Android installed app, never used, cannot receiver BroadcastReceiver
- Android-BroadcastReceiver 向 Activity 传值(电量显示)
- android 组件(activity,service,content provider,broadcast receiver,intent)详解
- android静态注册广播(BroadCastReceiver) Calling startActivity() from outside of an Activity
- Android两种BroadcastReceiver
- Androidc学习笔记三之BroadcastReceiver广播接收器及单双页模式
- Android四大组件之BroadcastReceiver
- Android ACTION_TIME_TICK BroadcastReceiver处理
- Android的四大组件之Broadcast Receiver
- Android BroadcastReceiver
- [Android] Android BroadcastReceiver 学习
- Android探索之BroadcastReceiver具体使用以及安全性探究
- Android四大组件-Broadcast Receiver
- Android深入浅出系列之实例应用—开机就运行自定义的程序BroadcastReceiver和intent-filter的用法
- android 广播机制Broadcast、BroadcastReceiver用法解读
- android-BroadcastReceiver 发送有序广播
- Android的BroadcastReceiver和EventBus区别是什么
- Android四大组件BroadcastReceiver 广播接收者
- Android Service BroadcastReceiver
- 名词解释:android中四大天王Activity、Service、Broadcast Receiver、Content Provid