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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T10:46:33+00:00 2026-06-08T10:46:33+00:00

Possible Duplicate: Run code when Android app is closed/sent to background In my android

  • 0

Possible Duplicate:
Run code when Android app is closed/sent to background

In my android app I need to be notified when users switching from my app to any other app, in order to do some security jobs. It can be by tapping on Back, Home button, through Recent Apps button. Any other ways?
Couldn’t find anything in android.app.Application.
I have many activities in the app, to put code in Activity.onPause() won’t work because it may goes to another activity in the same app. I need to find a way to be noticed.
Any good idea on this?
Thanks

  • 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-08T10:46:37+00:00Added an answer on June 8, 2026 at 10:46 am

    AFAIK there is no easy way of doing what you need.

    In our application we resort to polling current top activity, to check if it belongs to our application.

    ComponentName getTopActivity() {
        List<ActivityManager.RunningTaskInfo> runningTasks = activityManager.getRunningTasks(1);
        ActivityManager.RunningTaskInfo topTask = runningTasks.get(0);
        return topTask.topActivity;
    }
    

    I would really like to know is there any better way.

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

Sidebar

Related Questions

Possible Duplicate: Why does Android app run in small window on tablet emulator? i
Possible Duplicate: Can I run from command line program created by Eclipse? I am
Possible Duplicate: Change icon on of an App in iOS 4 in run-time Is
Possible Duplicate: Run a code in given time interval I have a method that
Possible Duplicate: Online PHP IDE In php it is possible to run code and
Possible Duplicate: Floating point comparison When I run the code below I get the
Possible Duplicate: Capture console exit C# When I run my console app and the
Possible Duplicate: How to force C# App to run as administrator on Windows 7
Possible Duplicate: How to run a database script file from Delphi? I have a
Possible Duplicate: Will code in finally run after a redirect? Hello, What happens when

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.