get Battery Status - Android Hardware

Android examples for Hardware:Battery

Description

get Battery Status

Demo Code


//package com.java2s;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;

public class Main {
    private static Intent getBatteryStatus(Context context) {
        IntentFilter filter = new IntentFilter(
                Intent.ACTION_BATTERY_CHANGED);
        return context.registerReceiver(null, filter);
    }//  ww  w . j  a v a2  s  .  c o  m
}

Related Tutorials