是安装后APP还没运行就想启动你新注册的服务吗?如果是的话 安装完后会发ACTION_PACKAGE_ADDED广播 但是Sorry the newly installed package does not receive this broadcast. 真要这样的话............. 楼下继续.
APP没启动系统怎么会知道有这个BoradcastReceiver呢?
可以在androidmanifest内注册广播
你可以在broatcast中 监控 ACTION_TIME_TICK ,来达到启动service。public static final String ACTION_TIME_TICK Since: API Level 1Broadcast Action: The current time has changed. Sent every minute. You can not receive this through components declared in manifests, only by exlicitly registering for it with Context.registerReceiver().This is a protected intent that can only be sent by the system. Constant Value: "android.intent.action.TIME_TICK"
字面上看也不行哦 You can not receive this through components declared in manifests, only by exlicitly registering for it with Context.registerReceiver(). 必须在代码里注册这个广播才能收到,也就是必须先运行APP。
一直工作在后台听着真不像是好需求哇Service自己不能运行,需要通过某一个Activity或者其它Context对象来调用,如Context.startService()和Context.bindService()两种方式启动Service。
可以在androidmanifest内注册广播
Since: API Level 1Broadcast Action: The current time has changed. Sent every minute. You can not receive this through components declared in manifests, only by exlicitly registering for it with Context.registerReceiver().This is a protected intent that can only be sent by the system.
Constant Value: "android.intent.action.TIME_TICK"
字面上看也不行哦 You can not receive this through components declared in manifests, only by exlicitly registering for it with Context.registerReceiver().
必须在代码里注册这个广播才能收到,也就是必须先运行APP。