[android-developers] Re: ACTION_POWER_CONNECTED broadcast receiver not recognize by ICS
public boolean isCharging(){
Intent iintent =
mContext.getApplicationContext().registerReceiver(null, new
IntentFilter(Intent.ACTION_BATTERY_CHANGED));
int status = iintent.getIntExtra(BatteryManager.EXTRA_STATUS,
-1);
return status == BatteryManager.BATTERY_STATUS_CHARGING;
}
On 8. Jan, 14:32 h., cl <cllam2...@gmail.com> wrote:
> I wanted to detect when the phone is pluged into the charger.
>
> I created a BroadcastReceiver as below
>
> public class PowerReceiver extends BroadcastReceiver {
> public void onReceive(Context context, Intent intent) {
> if (intent.getAction().equals(Intent.ACTION_POWER_CONNECTED))
> {
> Log.d("DEBUG", "Power connected...");
> }
> }
>
> }
>
> with following in the manifest
>
> <receiver android:name=".PowerReceiver" >
> <intent-filter>
> <action
> android:name="android.intent.action.ACTION_POWER_CONNECTED" />
> </intent-filter>
> </receiver>
>
> Everything work as expected on 2.2 (emulator and phone), but on ICS
> (emulator 4.0.3 and phone 4.0.1),
> the LogCat show
>
> 01-08 21:02:02.090: W/PowerUI(143): unknown intent: Intent
> { act=android.intent.action.ACTION_POWER_CONNECTED flg=0x10000010 }
>
> Anybody know reason, and a solution. Thanks.
--
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+unsubscribe@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

0 Comments:
Post a Comment
Subscribe to Post Comments [Atom]
<< Home