Android installed app, never used, cannot receiver BroadcastReceiver
2013-09-09 19:22
204 查看
官方文档是这么写的:(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之APP安装、更新、卸载的监听
- android_49_BroadcastReceiver_APP的状态监测
- [Android实例] 在 Android 中Service, Broadcast, BroadcastReceiver 的演示(转)
- android的广播broadcast和receiver && 广播接收器优先级的深入分析
- ClassCastException:android.app.Application cannot be to XXX的解决办法
- Android -- Android的广播机制(BroadcastReceiver)
- Android基础之BroadcastReceiver(待完善)
- Android面试常客--四大组件之BroadcastReceiver
- Android学习指南之二十一:Broadcast Receiver 的使用
- Android开发之如何保证Service不被杀掉(broadcast+system/app)
- Android四大组件之 BroadcastReceiver
- android成长日记 10.关于BroadcastReceiver的详细说明
- Android SharedPreferences与BroadcastReceiver简单结合
- Android的Broadcast Receiver组件
- Android四大组件之BroadCastReceiver
- Android两种方式监听短信内容---BroadcastReceiver和ContentObserver
- Testing Your Android GCM Broadcast Receiver
- Android四大组件之一 BroadcastReceiver解析
- Android中广播接收者BroadcastReceiver详解