ScreenShots:
BatteryBroadCast.java
package
com.swamys.batterybroadcast;
import
android.content.BroadcastReceiver;
import
android.content.Context;
import
android.content.Intent;
import
android.widget.Toast;
public class BatteryBroadcast extends BroadcastReceiver {
@Override
public void onReceive(Context
context, Intent intent) {
int battery_status =
intent.getIntExtra("level", 0);
Toast.makeText(context,
"" + battery_status,
Toast.LENGTH_LONG).show();
}
}
MainActivity.java
package
com.swamys.batterybroadcast;
import
android.app.Activity;
import
android.content.Intent;
import
android.content.IntentFilter;
import android.os.Bundle;
public class MainActivity extends Activity {
@Override
protected void onCreate(Bundle
savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
registerReceiver(new BatteryBroadcast(), new IntentFilter(
Intent.ACTION_BATTERY_CHANGED));
}
}
I had completely gothrow your post and it is full of innovative information.thanks for sharing this.
ReplyDeleteAndroid Training in Chennai
Android Training in Velachery
JAVA Training in Chennai
Python Training in Chennai
Hadoop Training in Chennai
Digital Marketing Course in Chennai
Android Training in Chennai
Android Training in T Nagar
Nice content! I like much more your post. I am always following with your blog...
ReplyDeleteSocial Media Marketing Courses in Chennai
Social Media Marketing Training in Chennai
Pega Training in Chennai
Primavera Training in Chennai
Unix Training in Chennai
Power BI Training in Chennai
Oracle Training in Chennai
Social Media Marketing Courses in Chennai
Social Media Marketing Training in Chennai