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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T18:47:16+00:00 2026-05-31T18:47:16+00:00

Hi, I am creating an app with tabactivity . But for security reasons i

  • 0

Hi, I am creating an app with tabactivity. But for security reasons i made changes and main screen will ask for password whenever the app is moved to background and started again or whenever the app is open, for that when an activity calls stop() then I am finishing the app by calling finish() and it is working. But the problem is I am not able to see the last tab which the user was viewing. I have used onsaveinstancestate() which is not working in this case. What is wrong with what I’m doing here. Is there any other approach for this? any suggestions are welcome
this is my stop method

 public void onStop()
{
    super.onStop();
 finish();
    System.out.println("In the onStop() event");
} 

  this is my code in tabactivity
protected void onSaveInstanceState (Bundle outState){
          outState.putInt("name",tabHost.getCurrentTab());

        super.onSaveInstanceState(outState);}
    protected void onRestoreInstanceState(Bundle outState){

        super.onRestoreInstanceState(outState);
         tabHost.setCurrentTab(outState.getInt("name")); 
    }
  • 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-31T18:47:17+00:00Added an answer on May 31, 2026 at 6:47 pm

    You need to save / restore the current tab yourself. You can do this using TabHost.set/getCurrentTab() and .get/setCurrentTabByTag(). The latter allows you to assign a string tag to the tab as opposed to dealing with the tabs by integer value.

    You can simply save the selected tab into shared preferences in onStop(), and restore it in onStart().

    Here’s some example code,

    http://code.google.com/p/csdroid/source/browse/trunk/src/org/jtb/csdroid/TabWidgetActivity.java

    Note that this restores the tab in onCreate(), and saves the current tab to prefs every time the tab is changed. This is not necessarily the best example, but it gives you an idea.

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

Sidebar

Related Questions

I'm creating and app that will rely on a database, and I have all
I am creating an app which will have a question in a UILabel and
I am creating an app on android but after hearing about sencha that it
I'm creating android app that has table layout for the main activity, and that
I'm creating app for image scan with WIA. But my images has a lot
We are creating an app with two main views: sView and sViewSettings. If the
I'm creating an app where people will be able to make posts for cities.
I am creating a app from a tutorial in a book, but I noticed
I'm creating an app in which the security is a critical matter. What concerns
I am creating an app that will require authentication which I have already gotten

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.