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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T03:40:33+00:00 2026-06-03T03:40:33+00:00

basically my app has a loginScreen and once logged u can go through many

  • 0

basically my app has a loginScreen and once logged u can go through many activities. when i press the home button the app goes in background and if the user doesnt open it within a certain amount of time, the users session closes and u return to the loginScreen. now the problem is that if i want to close the app from the loginScreen once my session has expired i press the back key and it should close but it doesnt. it brings me to the previous element in the stack.

the wired thing is that on all onBackPressed() methods and when ever i started new intents i always use intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
and on the loginScreen onBackPressed() i call finish()
but it doesnt work. anyone know why? and how do i solve this problem.

Thanks for the help!!!

code snippets
in many activities:

@Override
    public void onBackPressed() {
        mpButtonClick.start();
        Intent intent = new Intent(this, MenuPagina.class); 
        intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); 
        startActivity(intent); 
        super.onBackPressed(); 
    }

in the loginActivity:

@Override
    public void onBackPressed() {
        super.onBackPressed();
        getIntent().setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
        LoginActivity.this.finish();
    }
  • 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-03T03:40:36+00:00Added an answer on June 3, 2026 at 3:40 am

    You can do this two way:

    1. kill app by using android.os.Process.killProcess(android.os.Process.myPid()); on back press.

    for this you need to add below permission on manifest.

    <uses-permission
            android:name="android.permission.KILL_BACKGROUND_PROCESSES" />
    

    2 . use static boolean ‘isKill’ variable with default false and every time set false in login activity oncreate() method.

    set isKill value true in login activity onBackPress() method.

    And then write below code in every activity onResume() method

    if(isKill)
    {
        finish();
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Background: App has a shake to go home feature. Home view Only supports portrait.
I've created a custom button in my Android app that has basically two different
I'm busy working on a web app that basically has 5 pages that one
How can I build an android app which basically get the inputs from user
I am building an iPad app which basically has a UITabController which controls and
I have an app that has a custom background for a UITableView . Up
Basically, I want to create a button underneath a grouped table view, like contacts.app
The Kindle Fire has a bar at the bottom that includes a home button
my app has three buttons that each create a new intent like this: Button
My app has a datagrid as well as many other UIComponents (buttons, menus, etc).

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.