Today I create an application on the map, but it crashes when the battery is on.
How to check the event when the battery is on, for each device, help me. Thanks
I am trying to do this, but not working on API <21:
PowerManager powerManager = (PowerManager) this.getSystemService(Context.POWER_SERVICE); if ( powerManager.isPowerSaveMode()) { // Animations are disabled in power save mode, so just show a toast instead. Toast.makeText(customer_textReport.this, "Vui lòng tắt chế độ tiết kiệm pin", Toast.LENGTH_SHORT).show(); } else { Intent intentvitri = new Intent(customer_textReport.this, CustomerGetLocation.class); startActivityForResult(intentvitri, 111); }
source share