安卓。重新启动我的广播接收器。不工作。
当手机开机时,如何使用嵌套类在android中启动服务?
我的包包含嵌套类。
包名称
com.android
- MainActivity
- BroadCastReceiver
我正在尝试重新启动我的 BroadCast 接收器。但它不起作用(失败)。我不知道原因是否是由于嵌套类的任何问题。
<receiver android:name="ConnectionReceiver"></receiver>
<receiver android:name="com.android.MainActivity .BroadCastReceiver ">
<intent-filter>
<action android:name="android.intent.action.BOOT_COMPLETED" />
</intent-filter>
</receiver>
How to start a service in android using nested class when mobile is switched ON?
I have the package contains nested class.
package Name
com.android
- MainActivity
- BroadCastReceiver
I am trying to reboot my BroadCast receiver. But it doesn't work (getting Failed). I don't know if the reason is, because of any problems for nested classes.
<receiver android:name="ConnectionReceiver"></receiver>
<receiver android:name="com.android.MainActivity .BroadCastReceiver ">
<intent-filter>
<action android:name="android.intent.action.BOOT_COMPLETED" />
</intent-filter>
</receiver>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
清单文件
Onchip_BroadcastReceiver.java
Onchip_BackgroundService.java
manifest file
Onchip_BroadcastReceiver.java
Onchip_BackgroundService.java
R u 将 BroadcastReceiver 作为嵌套类。如果是,请不要这样做。
1)如果您将接收器作为嵌套类,请在活动中动态注册它,不要在清单中注册
2)如果您在清单中注册它,请为接收器创建单独的类。
R u having BroadcastReceiver as nested class. if yes dont do this.
1)if you have receiver as nested class, register it in activity dynamically, do not register in manifest
2) if you are registering it in manifest , make separate class for Receiver.