0

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?

Community
  • 1
  • 1
camelCaseD
  • 2,483
  • 5
  • 29
  • 44

1 Answers1

0

If the BroadcastReceiver and the Activity are in the same package, then you can:

  1. Create a BOOT_COMPLETED BroadcastReceiver (see http://www.androidcompetencycenter.com/2009/06/start-service-at-boot/)
  2. Read the preference in the receiver: I generally use SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context); in the receiver to get the global preferences object.
  3. 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).
  4. Show the notification using the NotificationManager.
Femi
  • 64,273
  • 8
  • 118
  • 148