Don't do this in a static. Once the static is set, it will hold that value until your process is killed, and you have no way of knowing when that will be.
On Tue, Jul 14, 2009 at 12:08 PM, Richard Schilling < richard.rootwirel...@gmail.com> wrote: > > Thanks everyone for your help. > > My bad. I do register in the body of the program instead of in the > manifest. So, scratch the part above about the manifest. > > I declare a static variable in the activity to keep track of whether > or not the registration has already happened. Perhaps the receiver is > being de-registered while the static boolean reference is kept alive > in the VM: > > > > public MyActivity extends Activity { > > private static boolean registeredBatteryIntent = false; > > @Override > public void onCreate(Bundle savedInstanceState) { > super.onCreate(savedInstanceState); > if (!registeredBatteryIntent){ > > IntentFilter filter = new IntentFilter > (Intent.ACTION_BATTERY_CHANGED); > MyReceiver receiver = new MyReceiver(); > this.registerReceiver(receiver, filter); > Log.i("Receiver.Registration", "registered intent > receiver."); > registeredBatteryIntent = true; > > > } > } > } > > Richard > > On Jul 14, 10:31 am, Mark Murphy <mmur...@commonsware.com> wrote: > > Richard Schilling wrote: > > > That's a good point. I will try registering the broadcast receiver > > > programmatically as well to see if there's a difference in behavior. > > > > The docs say you need to register BATTERY_CHANGED receivers in code, not > > via the manifest. > > > > "You can not receive this through components declared in manifests, only > > by exlicitly [sic] registering for it with Context.registerReceiver(). " > > > > http://developer.android.com/reference/android/content/Intent.html#AC... > > > > -- > > Mark Murphy (a Commons Guy)http://commonsware.com| > http://twitter.com/commonsguy > > > > Need help for your Android OSS project?http://wiki.andmob.org/hado > > > -- Dianne Hackborn Android framework engineer hack...@android.com Note: please don't send private questions to me, as I don't have time to provide private support, and so won't reply to such e-mails. All such questions should be posted on public forums, where I and others can see and answer them. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers-unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en -~----------~----~----~----~------~----~------~--~---