Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8183829
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T01:17:20+00:00 2026-06-07T01:17:20+00:00

My activity runs with a partial wake lock because it is continually handling received

  • 0

My activity runs with a partial wake lock because it is continually handling received Bluetooth data. The wake lock is set up like so:

  powerManager = (PowerManager) getSystemService(Context.POWER_SERVICE);
  wakeLock = powerManager.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, "MyWakeLock");
  wakeLock.acquire();

When certain events occur I want to on the display so the user can view the status. I want the display to turn on automatically, not by a user keypress.
However all attempts to do this have failed.
When the display turns off while running with a partial wake lock, my attempts to turn the display back and let the user see the current activity have failed. I have tried faking user activity:

PowerManager NewPowerManager = (PowerManager) getSystemService(Context.POWER_SERVICE);
   NewPowerManager.userActivity(1, false);

Setting flags for the window:

 Window win = getWindow();
  win.setFlags(WindowManager.LayoutParams.FLAG_TURN_SCREEN_ON, WindowManager.LayoutParams.FLAG_TURN_SCREEN_ON);

And even releasing the wake lock and starting another that should turn on the screen:

if (wakeLock != null)
   {
      wakeLock.release(); // release the wakelock
   }
PowerManager.WakeLock TempWakeLock = powerManager.newWakeLock(PowerManager.SCREEN_DIM_WAKE_LOCK |
   PowerManager.ACQUIRE_CAUSES_WAKEUP, "TempWakeLock");
   // tried | PowerManager.ON_AFTER_RELEASE to no avail
   TempWakeLock.acquire();

Is there something that I am missing here? I am not trying to open up a new activity, but merely displaying my current one to the user.
Has anyone else been able to do this?
Thanks for any help you can give me.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-07T01:17:22+00:00Added an answer on June 7, 2026 at 1:17 am

    I was finally able to resolve this issue after seeing some demo code from Lance at HTC (thanks by the way).

    The secret seems to be to create an additional full wake lock with ACQUIRE_CAUSES_WAKEUP set. I don’t release the original partial wake lock, but when I want to turn on the display I create the new full wake lock, do my stuff, then release the new full wake lock. This actually works!

    PowerManager TempPowerManager = (PowerManager) getSystemService(Context.POWER_SERVICE);
    PowerManager.WakeLock TempWakeLock = TempPowerManager.newWakeLock(PowerManager.FULL_WAKE_LOCK | PowerManager.ACQUIRE_CAUSES_WAKEUP | 
    PowerManager.ON_AFTER_RELEASE, "TempWakeLock");
    TempWakeLock.acquire();
    
    // do the work that needs the visible display...
    
    // Release the newest wakelock and fall back to the old one
    TempWakeLock.release();
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an activity that runs some ASCII control over a network port to
I have a Class A which runs activity via startActivityForResult by passing Intent to
In my application an activity starts a service which runs as a separate process,
My Activity creates an AsyncTask that loads data from a file and updates the
In activity I load preferences like: public void LoadFontSize(){ sharedPreferences = PreferenceManager.getDefaultSharedPreferences(getApplicationContext()); loadedFontSize =
I writed a activity just with a WebView that runs on an Android. The
So I've got an activity in my android app, that runs on start. This
If on run/debug configuration, if I specify a launch activity, then my app runs
I have a thread reading data from a bluetooth stream that sends the data
I have an activity that runs a query on a Sqlite DB, gets a

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.