How To Android Smartphones Current Status:-
A Simple android application to display the phone details, battery status and data connectivity status of an Android Smartphone.
Xml Files:-
1) main.xml
<?xml version="1.0" encoding="utf-8"?>
<TabHost xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@android:id/tabhost"
android:layout_width="match_parent"
android:layout_height="match_parent" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<TabWidget
android:id="@android:id/tabs"
android:layout_width="fill_parent"
android:layout_height="wrap_content" >
</TabWidget>
<FrameLayout
android:id="@android:id/tabcontent"
android:layout_width="match_parent"
android:layout_height="match_parent" >
</FrameLayout>
</LinearLayout>
</TabHost>
2) phonestatus.xml
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:scrollbarAlwaysDrawVerticalTrack="false"
android:scrollbarStyle="insideOverlay" >
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="#008080"
android:orientation="vertical" >
<!-- Service State -->
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal" >
<TextView
style="@style/labelStyleRight"
android:text="@string/tvServiceState"
android:textColor="#fff" />
<TextView
android:id="@+id/serviceState_info"
style="@style/textStyle"
android:textColor="#fff" />
</LinearLayout>
<!-- cell location -->
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal" >
<TextView
style="@style/labelStyleRight"
android:text="@string/tvCellLocation"
android:textColor="#fff" />
<TextView
android:id="@+id/cellLocation_info"
style="@style/textStyle"
android:textColor="#fff" />
</LinearLayout>
<!-- Call State -->
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal" >
<TextView
style="@style/labelStyleRight"
android:text="@string/tvCallState"
android:textColor="#fff" />
<TextView
android:id="@+id/callState_info"
style="@style/textStyle"
android:textColor="#fff" />
</LinearLayout>
<!-- Data Connection State -->
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal" >
<TextView
style="@style/labelStyleRight"
android:text="@string/tvConnState"
android:textColor="#fff" />
<TextView
android:id="@+id/connectionState_info"
style="@style/textStyle"
android:textColor="#fff" />
</LinearLayout>
<!-- Signal leve -->
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal" >
<TextView
style="@style/labelStyleRight"
android:text="@string/tvSignalLevel"
android:textColor="#fff" />
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="0.5"
android:orientation="horizontal" >
<ProgressBar
android:id="@+id/signalLevel"
style="@style/progressStyle" />
<TextView
android:id="@+id/signalLevelInfo"
style="@style/textSmallStyle"
android:textColor="#fff" />
</LinearLayout>
</LinearLayout>
<!-- Data Activity -->
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:weightSum="2" >
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="1" >
<TextView
style="@style/labelStyleRight"
android:text="@string/strData"
android:textColor="#fff" />
<ImageView
android:id="@+id/dataDirection"
style="@style/imageStyle" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:orientation="vertical" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:orientation="horizontal" >
<TextView
android:id="@+id/date"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Date : "
android:textColor="#fff"
android:textSize="15dp"
android:textStyle="bold" />
<TextView
android:id="@+id/date1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="hhhh"
android:textColor="#fff"
android:textSize="15dp"
android:textStyle="bold" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="5dp"
android:orientation="horizontal" >
<TextView
android:id="@+id/time"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Time : "
android:textColor="#fff"
android:textSize="15dp"
android:textStyle="bold" />
<TextView
android:id="@+id/time1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="hhhh"
android:textColor="#fff"
android:textSize="15dp"
android:textStyle="bold" />
</LinearLayout>
</LinearLayout>
</LinearLayout>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="vertical" >
<View
style="@style/Divider"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp" />
<TextView
android:id="@+id/device_info"
style="@style/labelStyleLeft"
android:textColor="#fff" />
</LinearLayout>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="vertical" >
<View
style="@style/Divider"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp" />
<TextView
android:id="@+id/device_info1"
style="@style/labelStyleLeft"
android:layout_gravity="center_vertical"
android:gravity="center"
android:text="Developed by parthiv MCA"
android:textColor="#fff" />
</LinearLayout>
</LinearLayout>
</ScrollView>
3) battery.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#008080"
android:orientation="vertical" >
<TextView
android:id="@+id/batterylevel"
style="@style/textStyleCenter"
android:textColor="#fff" />
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="vertical" >
<View
style="@style/Divider"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp" />
<TextView
android:id="@+id/device_info1"
style="@style/labelStyleLeft"
android:layout_gravity="center_vertical"
android:gravity="center"
android:text="Developed by parthiv MCA"
android:textColor="#fff" />
</LinearLayout>
</LinearLayout>
Java Files:-
4) StatusActivity
package com.parthiv.smartphonestatus;
import android.os.Bundle;
import android.app.TabActivity;
import android.content.Intent;
import android.view.Menu;
import android.view.Window;
import android.widget.TabHost;
import android.widget.TabHost.TabSpec;
@SuppressWarnings("deprecation")
public class StatusActivity extends TabActivity {
@SuppressWarnings("deprecation")
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
this.requestWindowFeature(Window.FEATURE_NO_TITLE);
setContentView(R.layout.main);
TabHost host = getTabHost();
TabSpec statusspec = host.newTabSpec("Phone");
statusspec.setIndicator("Phone",
getResources().getDrawable(R.drawable.nphone));
Intent phoneStatusIntent = new Intent(this, PhoneStatusActivity.class);
statusspec.setContent(phoneStatusIntent);
TabSpec batteryspec = host.newTabSpec("Battery");
batteryspec.setIndicator("Battery",
getResources().getDrawable(R.drawable.nbattery));
Intent batteryIntent = new Intent(this, BatteryStatusActivity.class);
batteryspec.setContent(batteryIntent);
// Adding all TabSpec to TabHost
host.addTab(statusspec);
host.addTab(batteryspec);
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
getMenuInflater().inflate(R.menu.phonestatus, menu);
return true;
}
}
5) PhoneStatusActivity
package com.parthiv.smartphonestatus;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Timer;
import java.util.TimerTask;
import android.app.Activity;
import android.os.Bundle;
import android.os.Handler;
import android.telephony.CellLocation;
import android.telephony.PhoneStateListener;
import android.telephony.ServiceState;
import android.telephony.TelephonyManager;
import android.telephony.gsm.GsmCellLocation;
import android.util.Log;
import android.view.Menu;
import android.widget.ImageView;
import android.widget.ProgressBar;
import android.widget.TextView;
public class PhoneStatusActivity extends Activity {
Handler handler = new Handler();
Timer timer = new Timer();
TimerTask timetask;
/*
* Signal level
*/
private static final int EXCELLENT_LEVEL = 75;
private static final int GOOD_LEVEL = 50;
private static final int MODERATE_LEVEL = 25;
private static final int WEAK_LEVEL = 0;
/*
*
* */
private static final int INFO_SERVICE_STATE_INDEX = 0;
private static final int INFO_CELL_LOCATION_INDEX = 1;
private static final int INFO_CALL_STATE_INDEX = 2;
private static final int INFO_CONNECTION_STATE_INDEX = 3;
private static final int INFO_SIGNAL_LEVEL_INDEX = 4;
private static final int INFO_SIGNAL_LEVEL_INFO_INDEX = 5;
private static final int INFO_DATA_DIRECTION_INDEX = 6;
private static final int INFO_DEVICE_INFO_INDEX = 7;
private static final int[] info_ids = { R.id.serviceState_info,
R.id.cellLocation_info, R.id.callState_info,
R.id.connectionState_info, R.id.signalLevel, R.id.signalLevelInfo,
R.id.dataDirection, R.id.device_info };
private TextView phoneStatusView;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.phonestatus);
Log.i("ONCREATE", "<<------- START ------- >>");
startSignalLevelListener();
displayTelephonyInfo();
Log.i("ONCREATE", "<<------- END ------- >>");
timetask = new TimerTask() {
public void run() {
handler.post(new Runnable() {
public void run() {
Calendar c = Calendar.getInstance();
SimpleDateFormat df = new SimpleDateFormat("dd-MM-yyyy");
SimpleDateFormat df1 = new SimpleDateFormat("HH:mm:ss");
String formattedDate = df.format(c.getTime());
String formattedDate1 = df1.format(c.getTime());
// txtResult
TextView result = (TextView) findViewById(R.id.date1);
result.setText("" + formattedDate);
TextView result1 = (TextView) findViewById(R.id.time1);
result1.setText("" + formattedDate1);
}
});
}
};
timer.schedule(timetask, 0, 1000); // Every 1 second
}
@Override
protected void onStop() {
super.onStop();
// Stop listening to the telephony events
StopListener();
}
@Override
protected void onPause() {
super.onPause();
// Stop listening to the telephony events
StopListener();
}
@Override
protected void onResume() {
super.onResume();
// subscribes to the telephony related events
startSignalLevelListener();
}
/*
* Sets the textview contents
*/
private void setTextViewText(int id, String text) {
((TextView) findViewById(id)).setText(text);
}
/*
*
* */
private void startSignalLevelListener() {
Log.i("startSignalLevelListener", "<<------- START ------- >>");
TelephonyManager tm = (TelephonyManager) getSystemService(TELEPHONY_SERVICE);
@SuppressWarnings("deprecation")
int events = PhoneStateListener.LISTEN_SIGNAL_STRENGTH
| PhoneStateListener.LISTEN_DATA_ACTIVITY
| PhoneStateListener.LISTEN_CELL_LOCATION
| PhoneStateListener.LISTEN_CALL_STATE
| PhoneStateListener.LISTEN_CALL_FORWARDING_INDICATOR
| PhoneStateListener.LISTEN_DATA_CONNECTION_STATE
| PhoneStateListener.LISTEN_SERVICE_STATE;
tm.listen(phoneListener, events);
Log.i("startSignalLevelListener", "<<------- END ------- >>");
}
/*
* De-register the telephony events
*/
private void StopListener() {
TelephonyManager tm = (TelephonyManager) getSystemService(TELEPHONY_SERVICE);
tm.listen(phoneListener, PhoneStateListener.LISTEN_NONE);
}
/*
* Display the telephony related information
*/
private void displayTelephonyInfo() {
Log.i("displayTelephonyInfo", "<<------- START ------- >>");
// access to the telephony services
TelephonyManager tm = (TelephonyManager) getSystemService(TELEPHONY_SERVICE);
// access to the gsm info ,..requires ACCESS_FINE_LOCATION and
// ACCESS_COARSE_LOCATION permission
GsmCellLocation gsmLoc = (GsmCellLocation) tm.getCellLocation();
// Get the IMEI code
String deviceid = tm.getDeviceId();
// Get the phone number string for line 1, for example, the MSISDN for a
// GSM phone
String phonenumber = tm.getLine1Number();
// Get the software version number for the device, for example, the
// IMEI/SV for GSM phones
String softwareversion = tm.getDeviceSoftwareVersion();
// Get the alphabetic name of current registered operator.
String operatorname = tm.getNetworkOperatorName();
// Get the ISO country code equivalent for the SIM provider's country
// code.
String simcountrycode = tm.getSimCountryIso();
// Get the Service Provider Name (SPN).
String simoperator = tm.getSimOperatorName();
// Get the serial number of the SIM, if applicable. Return null if it is
// unavailable.
String simserialno = tm.getSimSerialNumber();
// Get the unique subscriber ID, for example, the IMSI for a GSM phone
String subscriberid = tm.getSubscriberId();
// Get the type indicating the radio technology (network type) currently
// in use on the device for data transmission.
// EDGE,GPRS,UMTS etc
String networktype = getNetworkTypeString(tm.getNetworkType());
// indicating the device phone type. This indicates the type of radio
// used to transmit voice calls
// GSM,CDMA etc
String phonetype = getPhoneTypeString(tm.getPhoneType());
String deviceinfo = "";
deviceinfo += ("Device ID: " + deviceid + "\n");
deviceinfo += ("Phone Number: " + phonenumber + "\n");
deviceinfo += ("Software Version: " + softwareversion + "\n");
deviceinfo += ("Operator Name: " + operatorname + "\n");
deviceinfo += ("SIM Country Code: " + simcountrycode + "\n");
deviceinfo += ("SIM Operator: " + simoperator + "\n");
deviceinfo += ("SIM Serial No.: " + simserialno + "\n");
deviceinfo += ("Subscriber ID: " + subscriberid + "\n");
deviceinfo += ("Network Type: " + networktype + "\n");
deviceinfo += ("Phone Type: " + phonetype + "\n");
setTextViewText(info_ids[INFO_DEVICE_INFO_INDEX], deviceinfo);
}
private void setDataDirection(int id, int direction) {
int resid = getDataDirectionRes(direction);
// ((TextView)findViewById(id)).setCompoundDrawables(null,
// null,getResources().getDrawable(resid), null);
((ImageView) findViewById(id)).setImageResource(resid);
}
private int getDataDirectionRes(int direction) {
int resid = R.drawable.nodata;
switch (direction) {
case TelephonyManager.DATA_ACTIVITY_IN:
resid = R.drawable.indata;
break;
case TelephonyManager.DATA_ACTIVITY_OUT:
resid = R.drawable.outdata;
break;
case TelephonyManager.DATA_ACTIVITY_INOUT:
resid = R.drawable.bidata;
break;
case TelephonyManager.DATA_ACTIVITY_NONE:
resid = R.drawable.nodata;
break;
default:
resid = R.drawable.nodata;
break;
}
return resid;
}
private void setSignalLevel(int id, int infoid, int level) {
int progress = (int) ((((float) level) / 31.0) * 100);
String signalLevelString = getSignalLevelString(progress);
// set the status
((ProgressBar) findViewById(id)).setProgress(progress);
// set the status string
((TextView) findViewById(infoid)).setText(signalLevelString);
Log.i("signalLevel ", "" + progress);
}
private String getSignalLevelString(int level) {
String signalLevelString = "Weak";
if (level > EXCELLENT_LEVEL)
signalLevelString = "Excellent";
else if (level > GOOD_LEVEL)
signalLevelString = "Good";
else if (level > MODERATE_LEVEL)
signalLevelString = "Moderate";
else if (level > WEAK_LEVEL)
signalLevelString = "Weak";
return signalLevelString;
}
private String getNetworkTypeString(int type) {
String typeString = "Unknown";
switch (type) {
case TelephonyManager.NETWORK_TYPE_EDGE:
typeString = "EDGE";
break;
case TelephonyManager.NETWORK_TYPE_GPRS:
typeString = "GPRS";
break;
case TelephonyManager.NETWORK_TYPE_UMTS:
typeString = "UMTS";
break;
default:
typeString = "UNKNOWN";
break;
}
return typeString;
}
private String getPhoneTypeString(int type) {
String typeString = "Unknown";
switch (type) {
case TelephonyManager.PHONE_TYPE_GSM:
typeString = "GSM";
break;
case TelephonyManager.PHONE_TYPE_NONE:
typeString = "UNKNOWN";
break;
default:
typeString = "UNKNOWN";
break;
}
return typeString;
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
getMenuInflater().inflate(R.menu.phonestatus, menu);
return true;
}
private final PhoneStateListener phoneListener = new PhoneStateListener() {
/*
* call fwding
*/
public void onCallForwardingIndicatorChanged(boolean cfi) {
super.onCallForwardingIndicatorChanged(cfi);
}
/*
* Call State Changed
*/
public void onCallStateChanged(int state, String incomingNumber) {
String phoneState = "UNKNOWN";
switch (state) {
case TelephonyManager.CALL_STATE_IDLE:
phoneState = "IDLE";
break;
case TelephonyManager.CALL_STATE_RINGING:
phoneState = "Ringing (" + incomingNumber + ") ";
break;
case TelephonyManager.CALL_STATE_OFFHOOK:
phoneState = "Offhook";
break;
}
setTextViewText(info_ids[INFO_CALL_STATE_INDEX], phoneState);
super.onCallStateChanged(state, incomingNumber);
}
/*
* Cell location changed event handler
*/
public void onCellLocationChanged(CellLocation location) {
String strLocation = location.toString();
setTextViewText(info_ids[INFO_CELL_LOCATION_INDEX], strLocation);
super.onCellLocationChanged(location);
}
/*
* Cellphone data connection status
*/
public void onDataConnectionStateChanged(int state) {
String phoneState = "UNKNOWN";
switch (state) {
case TelephonyManager.DATA_CONNECTED:
phoneState = "Connected";
break;
case TelephonyManager.DATA_CONNECTING:
phoneState = "Connecting..";
break;
case TelephonyManager.DATA_DISCONNECTED:
phoneState = "Disconnected";
break;
case TelephonyManager.DATA_SUSPENDED:
phoneState = "Suspended";
break;
}
setTextViewText(info_ids[INFO_CONNECTION_STATE_INDEX], phoneState);
super.onDataConnectionStateChanged(state);
}
/*
* Data activity handler
*/
public void onDataActivity(int direction) {
String strDirection = "NONE";
switch (direction) {
case TelephonyManager.DATA_ACTIVITY_IN:
strDirection = "IN";
break;
case TelephonyManager.DATA_ACTIVITY_INOUT:
strDirection = "IN-OUT";
break;
case TelephonyManager.DATA_ACTIVITY_DORMANT:
strDirection = "Dormant";
break;
case TelephonyManager.DATA_ACTIVITY_NONE:
strDirection = "NONE";
break;
case TelephonyManager.DATA_ACTIVITY_OUT:
strDirection = "OUT";
break;
}
setDataDirection(info_ids[INFO_DATA_DIRECTION_INDEX], direction);
super.onDataActivity(direction);
}
/*
* Cellphone Service status
*/
public void onServiceStateChanged(ServiceState serviceState) {
String strServiceState = "NONE";
switch (serviceState.getState()) {
case ServiceState.STATE_EMERGENCY_ONLY:
strServiceState = "Emergency";
break;
case ServiceState.STATE_IN_SERVICE:
strServiceState = "In Service";
break;
case ServiceState.STATE_OUT_OF_SERVICE:
strServiceState = "Out of Service";
break;
case ServiceState.STATE_POWER_OFF:
strServiceState = "Power off";
break;
}
setTextViewText(info_ids[INFO_SERVICE_STATE_INDEX], strServiceState);
super.onServiceStateChanged(serviceState);
}
/*
*
* */
public void onSignalStrengthChanged(int asu) {
setSignalLevel(info_ids[INFO_SIGNAL_LEVEL_INDEX],
info_ids[INFO_SIGNAL_LEVEL_INFO_INDEX], asu);
super.onSignalStrengthChanged(asu);
}
};
}
6) BatteryStatusActivity
package com.parthiv.smartphonestatus;
import android.app.Activity;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.os.BatteryManager;
import android.os.Bundle;
import android.util.Log;
import android.widget.TextView;
public class BatteryStatusActivity extends Activity {
TextView textBatteryLevel = null;
String batteryLevelInfo = "Battery Level";
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.battery);
textBatteryLevel = (TextView) findViewById(R.id.batterylevel);
registerBatteryLevelReceiver();
}
/*
* Subscription to the Battery related Broadcast events and update the
* appropriate UI controls
*/
private BroadcastReceiver battery_receiver = new BroadcastReceiver() {
@Override
public void onReceive(Context context, Intent intent) {
boolean isPresent = intent.getBooleanExtra("present", false);
// Battery Technology
String technology = intent.getStringExtra("technology");
// Battery Plugged Information
int plugged = intent.getIntExtra("plugged", -1);
// Battery Scale
int scale = intent.getIntExtra("scale", -1);
// Battery Health
int health = intent.getIntExtra("health", 0);
// Battery Charging Status
int status = intent.getIntExtra("status", 0);
// Battery charging level
int rawlevel = intent.getIntExtra("level", -1);
int level = 0;
Bundle bundle = intent.getExtras();
Log.i("BatteryLevel", bundle.toString());
if (isPresent) {
if (rawlevel >= 0 && scale > 0) {
level = (rawlevel * 100) / scale;
}
String info = "Battery Level: " + level + "%\n";
info += ("Technology: " + technology + "\n");
info += ("Plugged: " + getPlugTypeString(plugged) + "\n");
info += ("Health: " + getHealthString(health) + "\n");
info += ("Status: " + getStatusString(status) + "\n");
setBatteryLevelText(info);
} else {
setBatteryLevelText("Battery not present!!!");
}
}
};
/*
* Battery Plugged Information
*/
private String getPlugTypeString(int plugged) {
String plugType = "Unknown";
switch (plugged) {
case BatteryManager.BATTERY_PLUGGED_AC:
plugType = "AC";
break;
case BatteryManager.BATTERY_PLUGGED_USB:
plugType = "USB";
break;
}
return plugType;
}
/*
* General health of the Battery
*/
private String getHealthString(int health) {
String healthString = "Unknown";
switch (health) {
case BatteryManager.BATTERY_HEALTH_DEAD:
healthString = "Dead";
break;
case BatteryManager.BATTERY_HEALTH_GOOD:
healthString = "Good";
break;
case BatteryManager.BATTERY_HEALTH_OVER_VOLTAGE:
healthString = "Over Voltage";
break;
case BatteryManager.BATTERY_HEALTH_OVERHEAT:
healthString = "Over Heat";
break;
case BatteryManager.BATTERY_HEALTH_UNSPECIFIED_FAILURE:
healthString = "Failure";
break;
}
return healthString;
}
/*
* Charging status of the Battery
*/
private String getStatusString(int status) {
String statusString = "Unknown";
switch (status) {
case BatteryManager.BATTERY_STATUS_CHARGING:
statusString = "Charging";
break;
case BatteryManager.BATTERY_STATUS_DISCHARGING:
statusString = "Discharging";
break;
case BatteryManager.BATTERY_STATUS_FULL:
statusString = "Full";
break;
case BatteryManager.BATTERY_STATUS_NOT_CHARGING:
statusString = "Not Charging";
break;
}
return statusString;
}
/*
* Battery Status TextView update
*/
private void setBatteryLevelText(String text) {
textBatteryLevel.setText(text);
}
/*
* Battery Related Broadcast event registration
*/
private void registerBatteryLevelReceiver() {
IntentFilter filter = new IntentFilter(Intent.ACTION_BATTERY_CHANGED);
registerReceiver(battery_receiver, filter);
}
}
Outputs:-
keep Updating Every Day...
No comments:
Post a Comment