BroadCast Battery Temperature

//OnCreate

IntentFilter iFilter = new IntentFilter(Intent.ACTION_BATTERY_CHANGED);
getApplicationContext().registerReceiver(mBroadcastReceiver,iFilter);



private BroadcastReceiver mBroadcastReceiver = new BroadcastReceiver() {
@Override
public void onReceive(Context context, Intent intent) {
float temperature = (float)(intent.getIntExtra(BatteryManager.EXTRA_TEMPERATURE,0))/10;
textview1.setText("Battery Temperature
" + temperature +" "+ (char) 0x00B0 +"C");
}
};

Komentar

Cara pembuatan Apps paling Populer

Create Stopwatch App in Android using Sketchware

TextInputLayout in Sketchware

How to find and​ highlight a word in a text field in Sketchware?

A Flash Light App in Sketchware

How to enable download in webview in Sketchware apps?

Intent - Open File By Type

Code for implementing Notifications in Sketchware

How to share an image from Drawable folder?

ActionBar back button

Animation Transtition Animation