Click here to Skip to main content
15,949,741 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Good evening everyone.
I'm a beginner in programming android (so you can tell me welcome)
and I need help on this subject "Android Application for managing the battery consumption of iphones".
I can not understand how one can recover the state (level) of the battery by an application under android.

thank you in advance friends
Posted

Something like.....

registerReceiver( batteryReceiver, new IntentFilter(Intent.ACTION_BATTERY_CHANGED) );


private BroadcastReceiver batteryReceiver = new BroadcastReceiver() {
@Override
public void onReceive( Context context, Intent intent )
{
int level = intent.getIntExtra( "level", 0 );
//do what ever you want with level
// check it or call UI update routine
}
}



/Darren
 
Share this answer
 
Ignoring the first link which is your question, you may find some suggestions here[^].
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900