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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T10:04:04+00:00 2026-05-18T10:04:04+00:00

I think I understood the Activity lifecycle on Android, but I still can’t figure

  • 0

I think I understood the Activity lifecycle on Android, but I still can’t figure why the followin is happening.

  • Login activity – Login screen
  • Main activity – Main application interface

In Login activity, I connect to a service to validate the login. If the password is correct, I switch to Main activity using:

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

There is no Options menu in Login activity.
I have an Options menu in Main activity that I inflate with:

    @Override
 public boolean onCreateOptionsMenu(Menu menu) {
     MenuInflater inflater = getMenuInflater();
     inflater.inflate(R.menu.option, menu);
     return true;
 }

So far so good. But I want the user to be able to log out and go back to login screen.
So in Main activity I have an option in the menu that allows logging out:

   @Override
 public boolean onOptionsItemSelected(MenuItem item) {
     // Handle item selection
     switch (item.getItemId()) {
     case R.id.menuReset:
      getModel().deleteCredentials // stuff to logout from my service
      startActivity(new Intent(this, LoginActivity.class));
      finish();
      return true;
     }
 } 

If I press that menu button, the application displays Login activity again. But if I press the MENU key, the application displays the menu from Main activity even if it’s not visible.

Furthermore, if I go back to home screen (pressing HOME) and come back to my activity after a while, the application displays the Login activity, but if I press the MENU key the Main application menu still shows.

How do I remove the menu from the Login activity?

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-05-18T10:04:04+00:00Added an answer on May 18, 2026 at 10:04 am

    Oooooops, my bad. The inflate menu code was accidentally copied and pasted to Login Activity when I was coping another piece of code 🙂

    Sorry about this
    Thanks anyway for the support!!

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

Sidebar

Related Questions

I read http://developer.android.com/reference/android/app/Activity.html but I have a question about PreferenceActivity lifecycle: Does a PreferenceActivity
I think I understand unit testing. But I was wondering: is there a way
I've been reading a lot about closures and I think I understand them, but
I have built an activity to handle gestures in my Android game and want
With this sample code, the activity is told to finish, but continues execution afterwards
So I have a very simple android activity that starts a timer when you
I'm trying to understand the Activity Testing tutorial on the Android site. One of
I thought I understood how C/C++ handled struct member alignment. But I'm getting strange
I understand how JS is run and I think I understand most of the
I have read the documentation on this and I think I understand. An AutoResetEvent

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.