Sunday, March 31, 2013

android,a Receiver intent is null


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

Google Voice on T-Mobile? [General]

Google Voice on T-Mobile? So I recently switched from a GNex on Verizon to a Moto X DE on T-Mobile. I had always used Google Voice for my v...