本文介绍了服务,无法启动在启动的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个接收器,在引导启动的服务,但接收方永远不会在开机的时候才
清单
<服务机器人:启用=真正的机器人:名字=。BatteryService>< /服务> < reciever机器人:名字=。BatteryReciever> &所述;意图滤光器> <作用机器人:名字=android.intent.action.BOOT_COMPLETED/> &所述; /意图滤光器> < / reciever><使用许可权的android:NAME =android.permission.RECEIVE_BOOT_COMPLETED/>为什么它不工作,一切看起来是正确的。
如果我打开我的应用程序服务启动正常
Receiver类
公共类BatteryReciever扩展广播接收器{ @覆盖 公共无效的onReceive(上下文为arg0,ARG1意向){ arg0.startService(新意图(arg0中,BatteryService.class)); } //结束onRecieve}解决方案
tyzyj,
看起来你可能拼错字接收在多个地方为收到。
尝试...
<接收机器人:名字=。BatteryReceiver> &所述;意图滤光器> <作用机器人:名字=android.intent.action.BOOT_COMPLETED/> &所述; /意图滤光器>< /接收器>除非类名称拼写错误呢?您可能要张贴的code为接收器类。
i have a receiver that starts a service at boot but the receiver never gets fired when at boot
manifest
<service android:enabled="true" android:name=".BatteryService"></service> <reciever android:name=".BatteryReciever"> <intent-filter> <action android:name="android.intent.action.BOOT_COMPLETED"/> </intent-filter> </reciever> <uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />why does it not work, everything looks correct
if i open my app the service starts fine
Receiver class
public class BatteryReciever extends BroadcastReceiver { @Override public void onReceive(Context arg0, Intent arg1) { arg0.startService(new Intent(arg0, BatteryService.class)); }//end onRecieve }解决方案
tyzyj,
It looks like you may have misspelled the word receive in multiple places as recieve.
Try...
<receiver android:name=".BatteryReceiver"> <intent-filter> <action android:name="android.intent.action.BOOT_COMPLETED"/> </intent-filter> </receiver>unless the class name is misspelled as well? You may want to post the code for that Receiver class.
更多推荐
服务,无法启动在启动
发布评论