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 [email protected]
To unsubscribe from this group, send email to
[email protected]
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.

Reply via email to