somehow my mind is not working and mild fever didn't help.
I have the following code, batteryLevel here shows the correct value - 50.
public class AlarmEventService extends Service {
static String batteryLevel;
...
int level = intent.getIntExtra("level", 0);
batteryLevel = String.valueOf(level);
Log.i(APP_TAG, batteryLevel);
}
Why in my outside call when I get value of AlarmEventService.batteryLevel the value is null?
public class AlarmEventReceiverWake extends BroadcastReceiver {
...
Log.i(APP_TAG, "Battery Level " + AlarmEventService.batteryLevel);
}
From what you have presented of the code, there is no reason why it shouldnt work as expected. It may be possibile that:
Make sure that the statement:
batteryLevel = String.valueOf(level);
is actually being called before
Log.i(APP_TAG, "Battery Level " + AlarmEventService.batteryLevel);
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.