this is my receiver.viewChanger is my original class .
public void onReceive(Context context, Intent intent) {
String action = intent.getAction();
viewChanger vc = new viewChanger();
if(action.equals("android.intent.action.TIME_TICK")){
vc.setDateView(context);
}else if(action.equals("android.intent.action.BATTERY_CHANGED")){
int level = intent.getIntExtra("level", 0);
vc.setBatteryView(level, context);
}else if(action.equals(Intent.ACTION_POWER_CONNECTED)){
int charging = intent.getIntExtra(BatteryManager.EXTRA_PLUGGED, -1);
vc.setAcusbView(charging, context);
}else if(action.equals(Intent.ACTION_POWER_DISCONNECTED)){
vc.setAcusbNullView(context);
}
}
my trouble is
int charging = intent.getIntExtra(BatteryManager.EXTRA_PLUGGED, -1);
this intent seems to be empty,charging get to be "-1" what is wrong for me?
.
forums.androidcentral.com
No comments:
Post a Comment