[android-developers] Re: Problem regarding Broadcast event android.intent.action.BATTERY_CHANGED
Thanks again mark for enlightening me :) But one more ques please. I have registered [ACTION_BATTERY_CHANGED] programmatically in activity A1. I am able to get broadcast event for battery change in A1. Now from that A1 started a new activity A2. But I am not able to get these broad cast event in Activity A2. Why so? Many many thanks AJ On Mar 25, 2:26 pm, Mark Murphy mmur...@commonsware.com wrote: AJ wrote: Hi group, I added broadcast listener BATTERY_CHANGED to Android Manifest file so that when the status changed I should get informed. I am adding to Android Manifest file as I want it active through my application life time. But the problem is that I am not getting the broad cast event from the system when battery status changes :( My code is here :- receiver android:name=.MyBroadcastReceiver android:enabled=true android:permission=android.permission.BROADCAST_STICKY intent-filter action android:name=android.intent.action.BATTERY_CHANGED / /intent-filter /receiver uses-permission android:name=android.permission.BATTERY_STATS/ uses-permission android:name=android.permission.BROADCAST_STICKY/ Can anybody please tell me what wrong I am doing here? You can not receive [ACTION_BATTERY_CHANGED] through components declared in manifests, only by explicitly registering for it with Context.registerReceiver(). See ACTION_BATTERY_LOW, ACTION_BATTERY_OKAY, ACTION_POWER_CONNECTED, and ACTION_POWER_DISCONNECTED for distinct battery-related broadcasts that are sent and can be received through manifest receivers. (from the docs for Intent) So, you either need to register this from some existing component, or switch to one of those other broadcast Intents. The rationale: Android does not want to start up a whole 'nuther process just because the battery level changed. -- Mark Murphy (a Commons Guy)http://commonsware.com|http://twitter.com/commonsguy Android Development Wiki:http://wiki.andmob.org -- 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 To unsubscribe from this group, send email to android-developers+unsubscribegooglegroups.com or reply to this email with the words REMOVE ME as the subject.
Re: [android-developers] Re: Problem regarding Broadcast event android.intent.action.BATTERY_CHANGED
AJ wrote: Thanks again mark for enlightening me :) But one more ques please. I have registered [ACTION_BATTERY_CHANGED] programmatically in activity A1. I am able to get broadcast event for battery change in A1. Now from that A1 started a new activity A2. But I am not able to get these broad cast event in Activity A2. If you registered a receiver for it in A2, I would expect you would get it. -- Mark Murphy (a Commons Guy) http://commonsware.com | http://twitter.com/commonsguy _Android Programming Tutorials_ Version 2.0 Available! -- 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 To unsubscribe from this group, send email to android-developers+unsubscribegooglegroups.com or reply to this email with the words REMOVE ME as the subject.
[android-developers] Re: Problem regarding Broadcast event android.intent.action.BATTERY_CHANGED
ok thanks again I have :- 1- class B extends BroadcastReceiver 2- class A1 extends ListActivity 3- class A2 extends Activity I make instance of B from A1 like :- B _intanceB = new B(this); and in B i register the [ACTION_BATTERY_CHANGED] How can I register it with A2 as you said? Thanks again for that AJ On Mar 25, 2:37 pm, Mark Murphy mmur...@commonsware.com wrote: AJ wrote: Thanks again mark for enlightening me :) But one more ques please. I have registered [ACTION_BATTERY_CHANGED] programmatically in activity A1. I am able to get broadcast event for battery change in A1. Now from that A1 started a new activity A2. But I am not able to get these broad cast event in Activity A2. If you registered a receiver for it in A2, I would expect you would get it. -- Mark Murphy (a Commons Guy)http://commonsware.com|http://twitter.com/commonsguy _Android Programming Tutorials_ Version 2.0 Available! -- 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 To unsubscribe from this group, send email to android-developers+unsubscribegooglegroups.com or reply to this email with the words REMOVE ME as the subject.
Re: [android-developers] Re: Problem regarding Broadcast event android.intent.action.BATTERY_CHANGED
AJ wrote: ok thanks again I have :- 1- class B extends BroadcastReceiver 2- class A1 extends ListActivity 3- class A2 extends Activity I make instance of B from A1 like :- B _intanceB = new B(this); and in B i register the [ACTION_BATTERY_CHANGED] How can I register it with A2 as you said? Copy and paste whatever you put in A1 into A2. If B is an inner class of A1, you might consider making it a regular full Java class, so you do not need two copies of that code. -- Mark Murphy (a Commons Guy) http://commonsware.com | http://twitter.com/commonsguy _Beginning Android 2_ from Apress Now Available! -- 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 To unsubscribe from this group, send email to android-developers+unsubscribegooglegroups.com or reply to this email with the words REMOVE ME as the subject.
[android-developers] Re: Problem regarding Broadcast event android.intent.action.BATTERY_CHANGED
ok many many thanks AJ On Mar 25, 2:54 pm, Mark Murphy mmur...@commonsware.com wrote: AJ wrote: ok thanks again I have :- 1- class B extends BroadcastReceiver 2- class A1 extends ListActivity 3- class A2 extends Activity I make instance of B from A1 like :- B _intanceB = new B(this); and in B i register the [ACTION_BATTERY_CHANGED] How can I register it with A2 as you said? Copy and paste whatever you put in A1 into A2. If B is an inner class of A1, you might consider making it a regular full Java class, so you do not need two copies of that code. -- Mark Murphy (a Commons Guy)http://commonsware.com|http://twitter.com/commonsguy _Beginning Android 2_ from Apress Now Available! -- 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 To unsubscribe from this group, send email to android-developers+unsubscribegooglegroups.com or reply to this email with the words REMOVE ME as the subject.
[android-developers] Re: Problem regarding Broadcast event android.intent.action.BATTERY_CHANGED
Just curious:- Can't I bind Broadcast event to an application or to some particular activities. SO that my all set of activities get all those broad cast event. Thanks AJ On Mar 25, 2:57 pm, AJ ajeet.invinci...@gmail.com wrote: ok many many thanks AJ On Mar 25, 2:54 pm, Mark Murphy mmur...@commonsware.com wrote: AJ wrote: ok thanks again I have :- 1- class B extends BroadcastReceiver 2- class A1 extends ListActivity 3- class A2 extends Activity I make instance of B from A1 like :- B _intanceB = new B(this); and in B i register the [ACTION_BATTERY_CHANGED] How can I register it with A2 as you said? Copy and paste whatever you put in A1 into A2. If B is an inner class of A1, you might consider making it a regular full Java class, so you do not need two copies of that code. -- Mark Murphy (a Commons Guy)http://commonsware.com|http://twitter.com/commonsguy _Beginning Android 2_ from Apress Now Available! -- 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 To unsubscribe from this group, send email to android-developers+unsubscribegooglegroups.com or reply to this email with the words REMOVE ME as the subject.
Re: [android-developers] Re: Problem regarding Broadcast event android.intent.action.BATTERY_CHANGED
AJ wrote: Just curious:- Can't I bind Broadcast event to an application or to some particular activities. SO that my all set of activities get all those broad cast event. Not really. -- Mark Murphy (a Commons Guy) http://commonsware.com | http://twitter.com/commonsguy Android Online Training: 26-30 April 2010: http://onlc.com -- 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 To unsubscribe from this group, send email to android-developers+unsubscribegooglegroups.com or reply to this email with the words REMOVE ME as the subject.
[android-developers] Re: Problem regarding Broadcast event android.intent.action.BATTERY_CHANGED
thanks again - AJ On Mar 25, 3:27 pm, Mark Murphy mmur...@commonsware.com wrote: AJ wrote: Just curious:- Can't I bind Broadcast event to an application or to some particular activities. SO that my all set of activities get all those broad cast event. Not really. -- Mark Murphy (a Commons Guy)http://commonsware.com|http://twitter.com/commonsguy Android Online Training: 26-30 April 2010:http://onlc.com -- 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 To unsubscribe from this group, send email to android-developers+unsubscribegooglegroups.com or reply to this email with the words REMOVE ME as the subject.