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

  • SEARCH
  • Home
  • 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 7702615
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T23:16:01+00:00 2026-05-31T23:16:01+00:00

I have found some interesting behavior and do not know why or how to

  • 0

I have found some interesting behavior and do not know why or how to get around it.
The activity is a singletask activity, which means onNewIntent() is for the activity while the activity is on the top of the stack. This works fine and well, while the phone’s screen is on. Once the screen is off however, the new intent is not received until the phone is “awake” and at that point the onNewIntent() is called. If the activity is not at the top of the stack and the phone is asleep then the activity is started and the onCreate() method is called.

The Activity declared as:

<activity android:name=".MyActivity" 
          android:launchMode="singleTask" 
          android:alwaysRetainTaskState="true" >

The Activity is also launched with the FLAG_ACTIVITY_NEW_TASK flag. The intent is launched from a broadcast receiver. If the phone is asleep and the intent is broadcast the activity wakes the phone up with these flags:

    getActivity().getWindow().addFlags(WindowManager.LayoutParams.FLAG_TURN_SCREEN_ON); 
    getActivity().getWindow().addFlags(WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED);

However the activity is not created until the phone is awake when it is on the top of the stack. Right now I am perplexed and not sure where to start. Also my activity uses onSaveInstanceState(). The activity is a FragmentActivity and contains one fragment.

Any help would be greatly appreciated!

  • 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-05-31T23:16:03+00:00Added an answer on May 31, 2026 at 11:16 pm

    However the activity is not created until the phone is awake when it
    is on the top of the stack.

    As far as i know, that’s by design. The only way to wake up the phone and keep it awake is by grabbing a wake lock.

    http://developer.android.com/reference/android/os/PowerManager.WakeLock.html

    The typical pattern is that you receive some intent to wake up your app, like the network state has changed, or whatever. In your receiver, in onHandleIntent(), you grab a wake lock. You start a service to do some work, and the service releases the wake lock after it is done.

    In your case, the receiver that sends the intent to your activity can grab a partial wake lock, then your activity can grab a screen wake lock. Keep in mind that as long as you hold the wake lock, the phone cannot sleep … causing it to use much more battery. Wake locks are very dangerous things for that reason.

    Note that you must do the lock hand off. If you don’t hold a wake lock when onHandleIntent() returns, the device can go right back to sleep. So it’d be something like,

    receiver: acquire partial lock
    activity: acquire screen lock
    activity: release partial lock
    

    You could also probably just grab the screen lock temporarily, then release it … the screen would come on, then go off normally according to the display timeout setting.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have found some in the Cappuccino website (vim, textmate and SubEthaEdit), but not
After googling a bit I have found some tips about how to get online
I recently came across the link below which I have found quite interesting. http://en.wikipedia.org/wiki/XOR_linked_list
I have found an interesting issue in windows which allows me to cause the
I have found few interesting things (for me at least) while generating random integers
comrades) I've found some interesting behavior of Invalidate method in multithreaded applications. I hope
I have found some libraries or web services in PHP that does the job.
I have found some info on the subject ( like this link) , but
I have found some code snippet in the internet. But it is missing some
I have found some code on measuring execution time here http://www.dreamincode.net/forums/index.php?showtopic=24685 However, it does

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.