Skip to content

Instantly share code, notes, and snippets.

Created June 20, 2021 00:08
What would you like to do?
Android Studio Battery Checker 2-1
public class BatteryReceiver extends BroadcastReceiver {
public void onReceive(Context context, Intent intent) {
TextView statusLabel = ((MainActivity)context).findViewById(;
TextView percentageLabel = ((MainActivity)context).findViewById(;
ImageView batteryImage = ((MainActivity)context).findViewById(;
String action = intent.getAction();
if (action != null && action.equals(Intent.ACTION_BATTERY_CHANGED)) {
// バッテリー情報を取得
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment