Questions tagged [powermanager]

PowerManager is a class in the Android SDK that gives control of the power state of the device.

PowerManager is a class in the Android SDK that 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.

Reference page: http://developer.android.com/reference/android/os/PowerManager.html

109 questions
0
votes
0 answers

Shared preferences inactive on app exit

Please help me out with my issue. I'm using preference fragment to let users choose to keep screen light on or allow the screen to go dim. This works well when you get in preferences but once you exit app, it doesn't work on next launch. Funny, if…
0
votes
1 answer

Keep alive a background thread using PARTIAL_WAKE_LOCK

I need to periodically run a task in background, and to keep awake the CPU. According to the Android documentation i used the PARTIAL_WAKE_LOCK for this purpose. In order to test the wake lock, i wrote a Service which starts a thread every 2 minutes…
Mattia Campana
  • 509
  • 2
  • 6
  • 15
0
votes
1 answer

Android - clear application data and reboot device

I am programming an Android-application with cordova. This app gets only installed on dedicated Android 5.1.1-devices. Among others I have the functionality to clear all the apps data. I have implemented this functionality in a cordova-plugin: // My…
Michael B
  • 1,660
  • 3
  • 28
  • 59
0
votes
0 answers

how to restart an android phone after x minutes through code

I want to restart my phone Suppose after 30 hrs. There is a api to shutdown phone but is there a api to restart phone? using android.os.PowerManager, function reboot(String reason), I guess we can reboot phone immediately, but how to reboot phone…
user1434287
  • 381
  • 3
  • 16
0
votes
1 answer

How to turn on screen again after user lock screen while activity is in foreground

Scenario: I have an activity that is running in foreground.. After a while, screen will auto lock. Later, I receive a new Intent that requires the screen to be shown again regardless of lock screen.. How should I turn on the screen while this…
xialin
  • 7,686
  • 9
  • 35
  • 66
0
votes
2 answers

how to stop the update of the widget android when I turn off the screen?

i'm creating an application with widget. The widget is updated every 10 seconds through AlarmManager, but I would that the AlarmManager stops when the screen is off, to prevent a possible battery drain. How can I do? I tried using PowerManager but…
gabg
  • 1
  • 1
0
votes
1 answer

Android L Battery Saver Mode - startActivityforResult

As you all might be aware the Android L has introduced a new feature called battery saver mode. I want direct the user from my app to that specific activity in the Settings page. How should I go about doing that? E.g.: For starting a "Data Usage…
0
votes
0 answers

Wakelock works only when screen turned on

many things has been written about wakelocks in Android. I'm using wakelock this way: PowerManager pm = (PowerManager) getSystemService(Context.POWER_SERVICE); partialWakeLock = pm.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK,…
skywall
  • 3,956
  • 1
  • 34
  • 52
0
votes
1 answer

Screen turn on without reason

I'm trying to build a standBy like activity, and I'm near to my goal, the only issue that I found is that sometimes after I switch off the screen Android turn it on immediately and I can't understand why. I have a terminal linked to a proprietary…
axl coder
  • 739
  • 3
  • 19
0
votes
2 answers

For which kinds of work I need to use CPU WAKE_LOCK in Sleep Mode?

For which kinds of work I need to use CPU WAKE LOCK ? For example in Sleep Mode I am using TelephonyManager getCellLocation(), should I use PARTIAL_WAKE_LOCK in this case or not? I didn't find this info in the documentation. P.S. TelephonyManager…
pvllnspk
  • 5,667
  • 12
  • 59
  • 97
0
votes
1 answer

Wakelock not working at all

What's missing in here? I want to wake up the device from sleep, but nothing happens. I certainly do not want to prevent sleeping. final Handler handler = new Handler(); Runnable runable = new Runnable() { @Override public…
Shervin
  • 233
  • 1
  • 13
0
votes
2 answers

Android screen wakeup only works with full_wake_lock

I have a service that listens to push notifications and creates an activity. Everything works well except when the device's screen is off. The desired behavior is that a notification would wake the screen up to the locked state homescreen and…
Nathaniel Wendt
  • 1,194
  • 4
  • 23
  • 49
0
votes
2 answers

After use PowerManager my device never goes to sleep mode anymore

I´m doing an app and I´m testing it on devices Samsung galaxy Y (Android 2.3.6) and Engel tablet 7" (Android 4.0.x). In my app´s code I´m using this snippet in order to wake up the devices(when they are in sleep mode) and works well , but now my…
JoCuTo
  • 2,463
  • 4
  • 28
  • 44
0
votes
1 answer

Assured wakeup of AsyncTask after Thread.sleep

I have a foreground service, which creates an asynctask in its onCreate(). The asynctask has a while(true)in its doInBackground. In this function, it performs certain network operation and goes to sleep for a random interval after each iteration.…
rahulserver
  • 10,411
  • 24
  • 90
  • 164
0
votes
0 answers

Turn the screen in to totally dark when press the button on the screen

How to code the android to turn the screen completely off just like you press the power button to lock your screen. I want the user to press the button on the screen and then screen goes off. I have tried (with permission): PowerManager.WakeLock wl…
Ricky Zheng
  • 1,279
  • 3
  • 16
  • 27