繁体   English   中英

CheckBox Preference Activity如何使用广播接收器从Intent.ACTION_BOOT_COMPLETED启动和停止服务

[英]CheckBox Preference Activity how to start and stop service from Intent.ACTION_BOOT_COMPLETED using broadcast receiver

在我的应用程序中,我有两个按钮可通过清单中的接收器类以及“包管理器”来启动和停止服务,这很好。

我想要的是给用户一个偏好活动,以使用(intent.getAction()。equals(Intent.ACTION_BOOT_COMPLETED))启动相同的服务。

我可以以(Intent.ACTION_BOOT_COMPLETED)开头该服务,但是由于我没有任何偏好活动,因此用户别无选择。

我什么都不知道! 关于首选项,除了在xml中为首选项创建复选框之外。

我需要的是让引导接收器知道首选项复选框的状态(对或错),并在引导完成时启动服务。

感谢您提供的任何帮助。

enter code here

This is my xml for the preference
<PreferenceScreen
 xmlns:android="http://schemas.android.com/apk/res/android">
<CheckBoxPreference

android:key="(intent.getAction().equals(Intent.ACTION_BOOT_COMPLETED))"
android:defaultValue="false"  
android:id="@+id/checkBox1" 
Preference" />

我本人已经通过研究和文档回答了这个问题,但研究和文档数量不多。看来,软件包管理器,待定的意图和接收者是完成任务的大部分需求。 再次感谢那些表现出兴趣的人。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM