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 7670511
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T15:50:21+00:00 2026-05-31T15:50:21+00:00

So I have my onResume command restarting a stopped thread which runs my game

  • 0

So I have my onResume command restarting a stopped thread which runs my game loop.
This works perfectly for resuming the app when closed by home button or by focusing on another app.
However, when you turn the screen off then on again, the activities onResume command fires right away before screen is unlocked. I need my activity to know when the screen is unlocked so it can restart the thread at the appropriate time.

Has anyone had this happen before?

  • 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-31T15:50:22+00:00Added an answer on May 31, 2026 at 3:50 pm

    for detect screen on and screen off register a broadcast reciver like:

    AndroidManifest.xml:

        <receiver android:name="receiverScreen">
            <intent-filter> 
                <action android:name="android.intent.action.SCREEN_ON" />
                <action android:name="android.intent.action.SCREEN_OFF" />
    <action android:name="android.Intent.ACTION_USER_PRESENT" />
            </intent-filter> 
        </receiver>
    

    In Activity or Service:

        try {
                  IntentFilter filter = new IntentFilter(Intent.ACTION_SCREEN_ON);
    
                  filter.addAction(Intent.ACTION_SCREEN_OFF);
    filter.addAction(Intent.ACTION_USER_PRESENT);
    
                  BroadcastReceiver mReceiver = new receiverScreen();
    
                  registerReceiver(mReceiver, filter);
             } catch (Exception e) {
    
             }
    

    receiver code where System inform you if Screen on/off happen:

     public class receiverScreen extends BroadcastReceiver {
    
         @Override
         public void onReceive(Context context, Intent intent) {
    
             if (intent.getAction().equals(Intent.ACTION_SCREEN_ON)){
    
             }
            if (intent.getAction().equals(Intent.ACTION_SCREEN_OFF)){
    
             }
    if (intent.getAction().equals(Intent.ACTION_USER_PRESENT)){
    
             }
         }
    
        }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I currently have a tapping game which utilises the on pause, stop and onresume
I have this scenario onResume of an activity: @Override protected void onResume() { if
I have an app that starts playing sounds and begins/resumes gameplay in the onResume()
I have a method that runs when the app is opened. It is called
I have FragmentA ,FragmentB ,FragmentC in ViewPager When app runs the first time I
I have a backgorund thread that extends AsyncTask and which I use in activity
I have an Alarm Manager which send Intent to BroadcastReceiver. This Broadcast is not
in my application i prompt for password in onResume(), and Before this i have
I made a music class that will play a song. I have made onResume
Have a look at this picture alt text http://www.abbeylegal.com/downloads/2009-04-01/web%20part%20top%20line.jpg Does anyone know what css

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.