Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

question about partial wakelock #15

Open
amunters opened this issue Mar 22, 2016 · 4 comments
Open

question about partial wakelock #15

amunters opened this issue Mar 22, 2016 · 4 comments

Comments

@amunters
Copy link

Hi,
thanks for the useful plugin, and also for the enhancement by Boltex.

My Android app fetches data periodically from a server. In order to keep the app running at all times I'm using Katzer's background plugin along with your powermanagemen plugin.
This works very well, however there is still one problem: the screen remain on all the time (unless I manually switch it off with the power button). Even when I switch to another app the screen remains on all the time.
I would like to have the screen go off automatically after some time of inactivity, just like any other app.
When I use window.powerManagement.acquire, the screen remains on with full brightness.
When I use window.powerManagement.dim, the screen will go dim after a while, but it will never go off completely.
How can I have the screen go completely off automatically as usual (while still keeping the app running)?

@amunters
Copy link
Author

Some extra comments:
As far as I understand there are 4 wakelock levels available in Android
(see http://developer.android.com/reference/android/os/PowerManager.html)

knipsel

I believe that in your plugin, window.powerManagement.acquire uses FULL_WAKE_LOCK
and window.powerManagement.dim uses SCREEN_DIM_WAKE_LOCK

However, for my app I think I would need PARTIAL_WAKE_LOCK to have the screen go off while still keeping the app running.
How can I accomplish this with your plugin?

@De-Lac
Copy link

De-Lac commented Mar 9, 2018

isn't that already managed by @boltex solution?

@boltex
Copy link

boltex commented Apr 18, 2018

indeed

@08Thug
Copy link

08Thug commented Dec 23, 2019

ionViewWillEnter(){
  powerManagement.acquire(function() {
    console.log('Wakelock acquired');
  }, function() {
    console.log('Failed to acquire wakelock');
  });
  }
ionViewWillLeave()
  {
    powerManagement.release(function() {
      console.log('Wakelock release acquired');
    }, function(err) {
      console.log('Failed release to acquire wakelock'+err);
    });
    
    powerManagement.dim(function() {
      console.log('Wakelock dim acquired');
    }, function(err) {
      console.log('Failed dim to acquire wakelock'+err);
    });
    
  }

@boltex after acquiring wakelock the screen stays Active after implementing release function the screen is still in active state.it stays active until we terminate the app.Does the release function revokes the powermanagement.acquire()-if it does then it should come back to normal state then the screen should go inactive(OFF) as we mentioned in device settings for screen saver.!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants