I may have asked a similar question before but i'm still having issues with my broadcast receiver being started when the phone boots up. So what I need to know is how to do a basic broadcast receiver that sends a status bar notification based on a checkbox preference from a different activity weather it's checked or not and how i'm suppose to list it in the manifest file?
Asked
Active
Viewed 205 times
1 Answers
0
If the BroadcastReceiver and the Activity are in the same package, then you can:
- Create a BOOT_COMPLETED BroadcastReceiver (see http://www.androidcompetencycenter.com/2009/06/start-service-at-boot/)
- Read the preference in the receiver: I generally use
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
in the receiver to get the global preferences object. - Use
getSystemService
to get the NotificationManager (see http://developer.android.com/reference/android/content/Context.html#getSystemService%28java.lang.String%29 and http://developer.android.com/reference/android/app/NotificationManager.html). - Show the notification using the NotificationManager.

Femi
- 64,273
- 8
- 118
- 148
-
Thx for the quick answer this looks like it will help a lot. – camelCaseD May 22 '11 at 19:22
-
How are you suppose to use the `getSystemService`? – camelCaseD May 22 '11 at 21:47
-
It is a method on the context you are passed to in the `onReceive` method. – Femi May 22 '11 at 21:52