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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T18:26:43+00:00 2026-05-25T18:26:43+00:00

First post, so please go easy. I have an app with a handful of

  • 0

First post, so please go easy.

I have an app with a handful of tabs, the first is opened on running the app.
One of the tabs is ‘My Account’ (a ListActivity) showing account options. I switch to this and if the user is not logged in, it, in turn, runs a UserLogon activity using the following:

Intent logonActivity = new Intent(getBaseContext(), UserLogon.class);
startActivityForResult(logonActivity, 0);

To catch the result, I use the following code:

protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    super.onActivityResult(requestCode, resultCode, data);
    if(requestCode == 0){
        MainBlock ta = (MainBlock) this.getParent();
        TabHost th = ta.getMyTabHost();
        th.setCurrentTab(0);
        finish();
    }
    if (requestCode == 100)
    {
        showAccountOptions();
    }
}

In the UserLogon class, I have the usual fare; TextView’s and Button’s. The intention is that if the user cancels the login, it will revert to the initial tab, or if login is successful, it will show the Account Options. And this is indeed what does happen.

All good so far.

The problem I’m having is that if I cancel the login and return to the first tab, when I select the Accounts tab again, I’m not presented with the UserLogon activity. I was under the impression that finish() would close the UserLogon activity, and the Accounts activity but it would appear not.

So, my question is simply, how do I, in effect, restart the Accounts activity so that the user would be presented with the option to login once more.

  • 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-25T18:26:43+00:00Added an answer on May 25, 2026 at 6:26 pm

    We’re good people and all willing to help 😉 I’ll give it a shot. Still, I’m not quite sure I get that all right.

    Basically you have an TabActivity which you setup and where you do something like that:

    myTabHost.setOnTabChangedListener(new OnTabChangeListener(){
    @Override
    public void onTabChanged(String tabId) {
        if (tabId.equals("account") && !loggedIn) {
            Intent logonActivity = new Intent(getBaseContext(), UserLogon.class);
            startActivityForResult(logonActivity, 0);
        }
    }});
    

    You’re basically saying that the first Activity start of UserLogon works, but the second one doesn’t, right? Did you debugged to that point to check whether you reach the code which starts the activity again?

    Update based on comment

    Your UserLogon should always provide a result information, here’s a blueprint:

    public class UserLogon extends Activity {
    
        public void onCreate(Bundle bundle) {
            // ... do something ...
    
            // if activity is canceled this will be the "last" result
            setResult(RESULT_CANCELED);
        }
    
        public void checkLoginOrSomethingLikeThat() {
            Intent result = new Intent();
            // put your results in this intent
            setResult(RESULT_OK, intent);
    
            // close activity since we have the information we need
            finish();
        }
    }
    

    The parent activity which is waiting for the result should do it like that:

    protected void onActivityResult(int requestCode, int resultCode, Intent data) {
        super.onActivityResult(requestCode, resultCode, data);
        // it's good practice to use a constant for 0 like LOGIN_REQUEST
        // otherwise you will ask yourself later "What the hell did 0 stand for?"
        if(requestCode == 0){
            if (resultCode == RESULT_OK) {
                // get needed data from data intent and react on that
            } else {
                // no success, react on that
            }
        }
    
        // ... I don't know what your resultCode 100 is but handle itwith the same pattern
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

first post here, and probably an easy one. I've got the code from Processing's
This is my first post, so please be nice :) I have a question
First post, please be kind. NOTE: I have reviewed entry #20856 (how to implement
First post and first iPhone app in the making here, so please excuse the
thats my first post, so please be kind. I have a matrix with 3~10
This is my first post on StackOverflow, so please be gentle... I have some
please be easy - first post! Looking to modify the following script: http://jonraasch.com/blog/a-simple-jquery-slideshow Love
My first post so please go easy on me! I know that there's no
This is my first post on Stack, so please bear with me if I
[please forgive formatting errors-- first post here and I tried earnestly to do it

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.