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
2
votes
3 answers

Lock The Android device screen and prevent the user to unlock it

I am working in Android App that should prevent the user to use the mobile in some-cases . So I tried to lock the screen I used the PowerManger goToSleeo() Method but it needs DEVICE_POWER permission. which is allowed only for the System apps, but…
Ahd Radwan
  • 1,090
  • 4
  • 14
  • 31
1
vote
0 answers

Android. Show notification in exact time

I have a question, that has been asked here many times, but I still can't find correct solution. I need to implement in an app a feature, that will show notification in exact time (for example, show notification every 30 minutes). I tried…
1
vote
0 answers

Android device wont switch on programatically

We have written a test app to try and debug a issue with a 3rd party by reproducing the issues with our own source code. The app has a feature to allow us to set times for when the devices switches off then on. This is to comply with green power…
TenG
  • 3,843
  • 2
  • 25
  • 42
1
vote
0 answers

PARTIAL_WAKE_LOCK vs IGNORE_BATTERY_OPTIMIZATION vs Whitelisting and which to use for a foreground service vs background service

Ever since doze mode got introduced in Marshmallow, and the further restrictions introduced with Oreo, doing continuous work in the background got harder. I read lots of articles that advise using either PARTIAL_WAKE_LOCK and…
Mena
  • 3,019
  • 1
  • 25
  • 54
1
vote
2 answers

Is it possible to turn off tv device via android tv app?

For my example I create simple TV app add button "power off" and tried to shut down my emulator where I run it. First of all i tried to find something in documentation here…
Vadim Eksler
  • 865
  • 9
  • 24
1
vote
1 answer

What if I don't UnregisterReceiver

What happens if I don't unregister a receiver? Will it slow down my app or causes app crash or throws some sort of exception? I need this receiver to be reigstered all time, even if app is closed: this.registerReceiver(broadcastReceiver, new…
AVEbrahimi
  • 17,993
  • 23
  • 107
  • 210
1
vote
1 answer

Prevent USB_DEVICE_ATTACHED launching app after a reboot

I have an activity listening for the USB_DEVICE_ATTACHED broadcast intent, which launches when the user plugs in my USB device and selects our app. My problem is the android host devices reboot themselves once a day (usually around 4am), at which…
Daniel Wilson
  • 18,838
  • 12
  • 85
  • 135
1
vote
1 answer

Using FLAG_KEEP_SCREEN_ON across the Android system

The goal of my app is to keep the screen on across the whole Android system. Previously, I've used FULL_WAKE_LOCK for this and it allowed me to block dimming of the screen across the system. However, since the API Level 17, it got deprecated: This…
yyunikov
  • 5,719
  • 2
  • 43
  • 78
1
vote
1 answer

How to turn on screen and open youtube app and keep the screen on?

I have an activity that is suppose to wake the screen up at a certain time and open up the YouTube app, I can turn the screen on, but if I add a startActivity on the YouTube app it doesn't turn on(the YouTube app starts but the screen stays off). …
1
vote
0 answers

Poking the Android PowerManager (like if the user had just interacted with it)

I have an external device connected to an android tablet. I would like that interactions with this external device have the same effect on power management that if the user interacted directly with the tablet. In other words, I'm looking for a way…
1
vote
0 answers

how to start the app on power button press in android

I want to launch(open) my app on single click of power button of android phone, How we detect single click event on power button. I tried onKey event but it detect only long click not single click. Anybody, have any idea? is there any broadcast…
khushhal goyal
  • 97
  • 2
  • 10
1
vote
1 answer

Leave from idle mode without using waking screen

I'm working on a application to send data to server every 20 mins. Here i found one difficulty because of android idle mode. In the time of idle mode the network access is been disabled to the apps as mentioned here. So in this time I can't able to…
Mahendran Sakkarai
  • 8,381
  • 6
  • 44
  • 66
1
vote
0 answers

Detect if user is currently present without receiver for ACTION_USER_PRESENT and ACTION_SCREEN_OFF

Is there a way to detect if the user is currently present without listening for the ACTION_USER_PRESENT-event and its counterpart ACTION_SCREEN_OFF? I don't like to cache the last event in SharedPrefs, because I can't listen for ACTION_SCREEN_OFF…
OneWorld
  • 17,512
  • 21
  • 86
  • 136
1
vote
0 answers

Aquire a "network" lock that locks wifi when it's used, but doesn't when 3G is used?

Currently I have this in my code: WifiManager.WifiLock wifiLock = ((WifiManager) context .getSystemService(Context.WIFI_SERVICE)) .createWifiLock(WifiManager.WIFI_MODE_FULL, "MyWifiLock"); wifiLock.aquire(); However my app uses "any" type…
Gavriel
  • 18,880
  • 12
  • 68
  • 105
1
vote
0 answers

Determine if screen is on or off on Android versions 15 - present

I am writing an SDK that will be used by Android devices with API level 15 and up. I'm currently targeting sdk version 22. What I'm trying to accomplish is to determine whether or not the screen is on or off. Sometimes I will be doing this while the…
neonDion
  • 2,278
  • 2
  • 20
  • 39