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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T11:03:33+00:00 2026-06-07T11:03:33+00:00

I have 2 activities. One called Login and another called ListDeals . Login has

  • 0

I have 2 activities. One called Login and another called ListDeals. Login has a form with a submit button which, when pressed, should switch our activity to ListDeals. This works.

However, in Logcat I don’t get a message saying that the activity has started. Also, when in ListDeals, if the user presses the back button, both activities should be killed. I looked around and this is what I came up with:

public class Login extends Activity {

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.login_screen);

    Button submit=(Button)findViewById(R.id.submit);
    submit.setOnClickListener(onSubmit);
}

private View.OnClickListener onSubmit=new View.OnClickListener() {

    @Override
    public void onClick(View view) {
        Intent myIntent=new Intent(view.getContext(),ListDeals.class );
        startActivityForResult(myIntent,0);

    }
};

@Override
public boolean onCreateOptionsMenu(Menu menu) {
    getMenuInflater().inflate(R.menu.login_screen, menu);
    return true;
}

@Override
public void onActivityResult(int requestCode,int resultCode, Intent data) {
    if(resultCode==2) {
        finish();
    } 
}

}

public class ListDeals extends Activity {
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.deals_list);
        System.out.println("starting activity");
    }

    @Override
    protected void onDestroy() {
        System.out.println("dude");
        setResult(2);
        super.onDestroy();


    }

    protected void onStop(){
        setResult(2);
        super.onStop();

    }

}

However, when I press the back button, It takes me back to the Login activity which is not what I want.

  • 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-07T11:03:34+00:00Added an answer on June 7, 2026 at 11:03 am

    In your click handler, onSubmit, just finish your login activity, like this. That way, it won’t be on the activity stack, and as a result, pressing back from your other activity will bring the user back to where they started.

    private View.OnClickListener onSubmit=new View.OnClickListener()
    {
        @Override
        public void onClick(View view)
        {
            Intent myIntent=new Intent(view.getContext(),ListDeals.class);
            startActivity(myIntent);
            finish();
        }
    };
    

    Also, to address you second question, use the Log class methods, such as Log.i or Log.d for debug messages, those will show up in logcat.

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

Sidebar

Related Questions

I have two activities, one is main and I have another activity called Test
I have an applications which has different activities. One of those activities can be
I have two activities, both of which use a listview. I called one android:list,
I have one class called Global and two other activities. In each activity I
I have a one main Workflow which calls several activities asynchronously. Some of the
I have two activities one displaying map view and another listview, the main objective
I have 2 activities, the first one is the startup one which in it's
I have a game with 2 activities: one is Startup, with a button guide
I have an Activity that has some form elements. This can be called from
My Application have 5 activities(A1,A2,A3,A4,A5). Each activity have one text view and one button(B1,B2,B3,B4,B5).

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.