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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T21:35:37+00:00 2026-05-30T21:35:37+00:00

I know that Android doesn’t have an Application-level onPause the way an Activity has

  • 0

I know that Android doesn’t have an Application-level onPause the way an Activity has an onPause, but it looks like I need a similar functionality. I asked a (dumb) question awhile ago (http://stackoverflow.com/questions/9508301/checking-the-manner-in-which-an-activity-has-been-reanimated) and realized that onPause/onResume will give me what I’m looking for: The ability to know if the Activity has been relegated to the background (either via the Home button, opening a different app, the phone sleeping, etc.).

The trouble is, onPause also fires in an Activity as I go from one Activity in my App to another. So I’m heading down the road of finding EVERY SINGLE way a user can go from Activity to Activity in my app (and there are anywhere from 15 to 25 of those) and setting a flag right before each user-initiated Activity switch. Then in onResume I’m checking that flag and if it’s X, I know that it was a user-initiated onResume. If the flag is Y, I know that it’s a result of the Home button being pressed, the phone sleeping, etc.).

This just seems like a big messy kludge. Is there a better way?

(I add this to help, not to confuse: My goal is to have a (very annoying, I know) passcode screen that pops up any time the app goes away from the foreground for any reason (even screen sleep). I planned to use onPause/onResume to check when to pop the Passcode activity, but onPause fires every time I change Activities and therefore I need to add more.)

  • 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-30T21:35:39+00:00Added an answer on May 30, 2026 at 9:35 pm

    Apps like Pinnacle Locker do something similar–I believe they intercept an Intent for specific packages, and thus are fired whenever the system switches to an app, but not when the user changes screens between apps.

    I may be misunderstanding you, but another approach would be to turn your approach around: whenever you change from one screen to the other inside an app, you are either launching an Intent or finish()ing (such as when the user presses the back button), right?

    Then you could set a flag in your internal Intents, and whenever you directly call finish() or when onBackPressed() is called in your apps you could set a similar flag. If that flag is not set when onResume() runs in your app, then you could show the lockscreen.

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

Sidebar

Related Questions

I know that Android has a JSON parser baked in but I was wondering
I know that android doesn't highlight anything in TouchMode. But I am doing something
Of course and I know that JPanel doesn't exists in Android, but when I
Now that Google Earth has been released for Android 2.1, does anyone know what,
I know that I can do something like $int = (int)99; //(int) has a
I know that |DataDirectory| will resolve to App_Data in an ASP.NET application but is
Android doesn't appear to provide a way for a user application to change the
It's well-known on Android discussion forums and SO that Android's API doesn't have a
So I have a TextView in android that has the width of the whole
I know Android doesn't support MJPEG natively but are there any jar files/drivers available

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.