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

  • Home
  • SEARCH
  • 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 7818205
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T06:30:10+00:00 2026-06-02T06:30:10+00:00

My application has screens and there is only one activity. My main activity is

  • 0

My application has screens and there is only one activity. My main activity is like: I have methods for calling the screen, I didn’t use activity (I read somewhere that usage is more complicated.) So I used methods, but there is one problem.

When I open the activity the loginScreen is coming OK

When I click the loginBtn the listScreen is coming OK

But, when I click the back button in listScreen for coming back to loginScreen, the app is closing and open the home screen of emulator.

Normally;

loginScreen –> loginBtn –> listScreen –> listBtn –> writeScreen

What I want is coming back on this path with “back” button on emulator. I don’t want to do that with override the back button because with this way I can only set one thing into the method.

public class EmailActivity extends Activity 
{
public void onCreate(Bundle savedInstanceState) 
        {
        super.onCreate(savedInstanceState);
        // setContentView(R.layout.main);
        loginScreen();
    }

public void loginScreen() 
{
        this.setContentView(R.layout.main);
                Button loginBtn = (Button) findViewById(R.id.btnLogin);

        loginBtn.setOnClickListener(new Button.OnClickListener() {

            @Override
            public void onClick(View v) 
                        {
                listScreen();
            }

        });
}

public void listScreen()
{
            this.setContentView(R.layout.list);
                Button listBtn = (Button) findViewById(R.id.btnList);

        listBtn.setOnClickListener(new Button.OnClickListener() {

            @Override
            public void onClick(View v) 
                        {
                setContentView(R.layout.writeScreen);
            }

        });

}
  • 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-02T06:30:12+00:00Added an answer on June 2, 2026 at 6:30 am

    Because you must write an Activity for each screen you use in the app… you are just calling methods, and in memory you have just one Activity so, the back button pop the Activity and return to the home…
    Read this:
    http://developer.android.com/guide/topics/fundamentals/tasks-and-back-stack.html

    If you wanna call another screen(Activity)m you create an instance of a Intent, which tells the system “hey!, call the stuff i’m passing here”, for example, you have two activities, called, A1 and A2, if you wanna call A2 from A1, you must do this:

    Intent intent = new Intent(A1.this,A2.class);
    startActivity(intent);
    

    It will push A2 over A1, so when you press back, you will get A1

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

Sidebar

Related Questions

In my application I have several activities, the main screen has 4 buttons that
I have an app which has a main activity that calls other activities on
I have one iphone application in which recurring events happens.the duration are like every
I am creating a web application which has a few management screens, where a
My application has no forms. It runs by calling Application.Run();
I'm working on an ASP.NET web application. There's a bill page which has two
When your application has a view that is only accessible after submitting another form
In our Android app, I have an activity that has a gridview that displays
My application has three activities say A -> B-> C . Activity A is
My application has a following requirement. 1) First screen has two tabs. 2) From

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.