服务,无法启动在启动

编程入门 行业动态 更新时间:2024-10-22 21:19:29
本文介绍了服务,无法启动在启动的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我有一个接收器,在引导启动的服务,但接收方永远不会在开机的时候才

清单

<服务机器人:启用=真正的机器人:名字=。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.

更多推荐

服务,无法启动在启动

本文发布于:2023-10-16 16:22:23,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1498085.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:无法启动

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!