Questions tagged [android-powermanager]

Tag for Android PowerManager questions - class, that gives you control of the power state of the device.

This class gives you control of the power state of the device.

Device battery life will be significantly affected by the use of this API. Do not acquire PowerManager.WakeLocks unless you really need them, use the minimum levels possible, and be sure to release them as soon as possible.

You can obtain an instance of this class by calling Context.getSystemService().

The primary API you'll use is newWakeLock(). This will create a PowerManager.WakeLock object. You can then use methods on the wake lock object to control the power state of the device.

Useful links

70 questions
59
votes
4 answers

Check if battery optimization is enabled or not for an app

Android 6 and 7 have some power optimizations (doze mode) which restrict app networking when device is not used. User may disable optimization mode for any app in Battery settings: Is it possible to check if optimization is enabled for my app or…
Nik
  • 7,114
  • 8
  • 51
  • 75
25
votes
4 answers

Force an android phone to sleep, in order to test?

I'm writing an android application that depends on network activity and the alarm manager sometimes waking the phone up from a sleeping state. My question is how can I reliably test this on device? Ideally, how can I force the phone into a full-on…
Chris Best
  • 251
  • 1
  • 3
  • 3
22
votes
3 answers

When does android device go to sleep mode?

I was searching SO and web but i couldn't find sufficient answer for my particular question. Ok here we go: Every user can modify screen timeout on android. (when screen turns off when its idle for __ seconds/minutes - users choice ). But user can…
rootpanthera
  • 2,731
  • 10
  • 33
  • 65
12
votes
1 answer

Return a failure result in inKeyguardRestrictedInputMode()

I have a function to determine four states of phone's screen: screen on, screen off, screen on with lock, screen on without lock. My function is private KeyguardManager keyguardManager; public String getScreenStatus() { String…
user3051460
  • 1,455
  • 22
  • 58
12
votes
2 answers

How do I avoid that my App enters optimization on Samsung devices

Smart manager kills an app that hasn't been used for 3 days. My app does some background work and hence, the user doesn't need to open it. What can I do so that it doesn't enter app optimization mode ( Android OS 5.0.2, 5.1.1)
lyc001
  • 777
  • 1
  • 10
  • 25
12
votes
1 answer

Unlock the Screen Programmatically

I have a share button in the GCM notification. On click of the share button, I need to launch share intent. Everything works perfectly. Only problem that I'm facing is Lollipop lock screen feature. When I click share button from lock screen, my…
10
votes
1 answer

Android 12 Battery optimization

I am trying to check if Android 12 is optimizing my app battery usage, so I used isIgnoringBatteryOptimizations method ( https://developer.android.com/reference/android/os/PowerManager#isIgnoringBatteryOptimizations(java.lang.String)). But…
AVEbrahimi
  • 17,993
  • 23
  • 107
  • 210
10
votes
0 answers

App standby bucket does not acknowledge user interaction

I have a VOIP application which uses HIGH priority push notifications each time a call is performed. The push notification is message notification since I want to handle interaction myself. When I receive push I start a foreground service which…
Tadej Vengust
  • 1,351
  • 4
  • 18
  • 35
8
votes
2 answers

Android P Beta - AlarmManager Notifications not working

I'm testing my application on Android P beta release 4. My app's targetSdkVersion is 27 It has been observed that alarm manager notifications are not working as expected. I'm using below code to set the notifications - if…
6
votes
3 answers

Exclude Android app from being put into standby bucket

With Android 9 battery optimization has been pushed further and apps are classified into standby buckets depending on how much the user has recently interacted with the app (see Android documentation). The system limits the device resources…
5
votes
0 answers

Getting around Meizu App Auto-Clean

I am having a problem where a Meizu phone is killing my Application, because of what seems to be a Meizu specific setting, where apps are killed after running and consuming power in the background for 3 minutes, after standby. Certain apps on the…
slayerpjo
  • 173
  • 1
  • 11
4
votes
1 answer

How to programmatically determine if an Android app is put to sleep on Samsung Galaxy?

Samsung Galaxy has the feature to put apps to sleep - which to my understanding is not the same as battery optimization for apps. I need to programmatically check if an app is configured to sleep so I can properly warn the user about this and the…
Seb T
  • 795
  • 8
  • 16
4
votes
1 answer

How to detect that user removed my app from "Not optimized" list in battery optimization?

I have an app that needs to ignore doze mode and it asks the user to add it to not optimized apps list the usual way with: Intent intent = new Intent(); String packageName = getPackageName(); …
Ognyan
  • 13,452
  • 5
  • 64
  • 82
4
votes
4 answers

Service goes to standby when device sleeps - Android

Envrionment: Eclipse Language: Java (Android) I have a bit of a problem, which I didn't realise until I tested my application out on a device. I always thought that services would continuously be running in the background, even when the phone's…
user959631
  • 1,004
  • 2
  • 14
  • 34
3
votes
1 answer

Android wakeLock issue

I have foreground service. Manifest contains this permissions: In Splash activity i request…
1
2 3 4 5