Skip to content

Instantly share code, notes, and snippets.

@codeforfun-jp
Created June 20, 2021 01:31
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save codeforfun-jp/357188118b3d84445c020f54cad76ad7 to your computer and use it in GitHub Desktop.
Save codeforfun-jp/357188118b3d84445c020f54cad76ad7 to your computer and use it in GitHub Desktop.
Android Studio Battery Checker 3-1
public class MainActivity extends AppCompatActivity {
private final BatteryReceiver batteryReceiver = new BatteryReceiver();
private final IntentFilter intentFilter = new IntentFilter(Intent.ACTION_BATTERY_CHANGED);
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
}
@Override
protected void onResume() {
super.onResume();
registerReceiver(batteryReceiver, intentFilter);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment