我之前可能会问过类似的question,但是当手机启动时我的广播接收器仍然存在问题。所以我需要知道的是如何做一个基本的广播接收器,根据来自不同活动天气的复选框偏好发送状态栏通知,它是否被检查?我想如何在清单文件中列出它?
答案 0 :(得分:0)
如果BroadcastReceiver和Activity在同一个包中,那么您可以:
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
来获取全局首选项对象。getSystemService
获取NotificationManager(请参阅http://developer.android.com/reference/android/content/Context.html#getSystemService%28java.lang.String%29和http://developer.android.com/reference/android/app/NotificationManager.html)。