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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T04:12:22+00:00 2026-06-01T04:12:22+00:00

I have onPause in activity and works great. This is code @Override protected void

  • 0

I have onPause in activity and works great. This is code

@Override
protected void onPause() {
    super.onPause();
    Intent intent;

    intent = new Intent(Games.this, PauseScreen.class);
    startActivity(intent);

}

But I have a problem. When I push the back button onPause is calling and start new activity. I want to onPause works always except when I click back button on my phone. How I can do this? I think that may be if(backbutton was click){onPause is not working}else{onPause working} but I don’t know how implement this solution. Or maybe you have better idea?

  • 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-01T04:12:26+00:00Added an answer on June 1, 2026 at 4:12 am

    @user1302569

    Here are step you can follow to achieve your desire behavior in Application..

    STEP 1: Overide this back Key method in your Activty.

    @Override
      public void onBackPressed() {
                 //Here you get Back Key Press So make boolean false
                 no_back_key=false;
                 super.onBackPressed();
    } 
    

    STEP 2: Take One boolean variable like below in your Activity Class.

     public boolean no_back_key=true;
    

    STEP 3: in your OnPause Method do some thing like Below

               @Override
               protected void onPause() {
               super.onPause();
               Intent intent;
               //Only this boolean will become false when we get Back Key Press as you Said in Your   Question
               if(no_back_key){
               intent = new Intent(Games.this, PauseScreen.class);
               startActivity(intent);
        }
    

    STEP 4: in Your Activity’s OnResume Make sure this also.

        @Override
        protected void onResume() {
        no_back_key=true;
        super.onResume();
    }
    

    }

    Regarding Back Key Event in Android ,in Developer site you can refer this http://android-developers.blogspot.in/2009/12/back-and-other-hard-keys-three-stories.html

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

Sidebar

Related Questions

I have the following code: SharedPreferences KITPrefs; EditText passPhraseExample; ... @Override public void onCreate(Bundle
I have an activity that starts a service like that: Intent youtubeIntent = new
I have overridden the finish call in a sub-activity like so @Override public void
I have the following scenario: I have a chat activity, in it's intent it
I think I’m doing this right? I have this code which starts looking for
Imagine that I have an Activity A and I'm starting a new activity B
Have you guys had any experiences (positive or negative) by placing your source code/solution
Have you managed to get Aptana Studio debugging to work? I tried following this,
I have 2 activities. In child activity i have put something like that in
I have a main activity and a sub activity. The main activity starts the

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.