首先创建/res/xml/settings.xml

<?xml version="1.0" encoding="utf-8"?><PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android" >    <CheckBoxPreference        android:defaultValue="true"        android:key="@string/cbp_push_notification"        android:summaryOff="关闭推送通知"        android:summaryOn="启动推送通知"        android:title="推送通知" />    <CheckBoxPreference        android:defaultValue="true"        android:dependency="@string/cbp_push_notification"        android:key="@string/cbp_push_sound"        android:summaryOff="关闭声音"        android:summaryOn="开启声音"        android:title="推送声音" />    <CheckBoxPreference        android:defaultValue="true"        android:dependency="@string/cbp_push_notification"        android:key="@string/cbp_push_vibrate"        android:summaryOff="关闭震动"        android:summaryOn="开启震动"        android:title="推送震动" /></PreferenceScreen>
然后在PreferenceActivity里添加该资源

public class NotificationSettingsActivity extends PreferenceActivity {@Overrideprotected void onCreate(Bundle savedInstanceState) {super.onCreate(savedInstanceState);addPreferencesFromResource(R.xml.settings);}}

使用该配置要调用

SharedPreferences defaultSp = PreferenceManager.getDefaultSharedPreferences(context);return defaultSp.getBoolean(context.getString(R.string.cbp_push_notification),true);

更多相关文章

  1. Android判断app是否打开消息通知并跳转设置
  2. 基于百度推送android notification的使用之合并通知栏
  3. Android 8.0和8.1通知栏
  4. android 自定义通知消息设置背景色不生效,导致部分机型显示白色字
  5. Android——自定义通知栏使用
  6. Android耳机声音自动调整
  7. Android通知
  8. Android监听系统通知
  9. Android消息通知

随机推荐

  1. Android最快的模拟器Genymotion试用小结
  2. Android判断程序是否第一次运行
  3. Android闹钟设置的解决方案
  4. Android中hybrid开发的基础知识
  5. android基础学习--->adapter那点事儿
  6. Android中有几种数据存储方式,每种方式有
  7. Android(安卓)ApiDemo学习(五)Animation—
  8. HTML中的javascript交互
  9. Android(安卓)Gradle系列-入门篇
  10. 为Android开发环境安装BlackBerry PlayBo