How can i notify the user if battery is need to be replace in android
<p>I want to develop an android application that will tell me if the battery of the phone is in good condition or if it needs to be replaced. can someone shed some light for me? I'm looking for an api for this but i cant seem to find one...</p>

<p>is this correct sir? </p>

<pre><code>public class BatteryInformationActivity extends Activity {
    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);

        IntentFilter ifilter = new IntentFilter(Intent.ACTION_BATTERY_CHANGED);
        Intent batteryStatus = registerReceiver(null, ifilter);
        if (batteryStatus.hasExtra(BatteryManager.EXTRA_HEALTH)) {
            int health = batteryStatus.getIntExtra(BatteryManager.EXTRA_HEALTH,
                    BatteryManager.BATTERY_HEALTH_GOOD);
            if (health != BatteryManager.BATTERY_HEALTH_GOOD) {
                Toast.makeText(this, "Battery has a problem",
                        Toast.LENGTH_SHORT).show();

            }

        }

    }

}
</code></pre>
