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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T09:42:56+00:00 2026-05-23T09:42:56+00:00

I’m having this error with backbutton on my activities. All activities have this problem.

  • 0

I’m having this error with backbutton on my activities. All activities have this problem. When I press Back Button it goes to home screen, not to last activity in stack. I’ve putted a Log message but in some activities it doesn’t print it on LogCat, in this activity posted here it prints the log. But it looks like for some activities is not going inside the method.

There are three tabs in my application, one of them extends ActivityGroup instead of Activity. But I don’t think its the problem, I’ve removed this tab and it keeps happening.

So my question is, how do I solve it, how do I make it go to last activity instead going to home screen?

In fact it goes to the last screen where it was called. If I call it on the home screen it goes to this, if I call it on the main screen, where I put shortcuts and widgets it goes to this screen.
And for what I’ve read in docs, it should go to the last in history stack, which means that this screen is on the stack, but no my activities. Right?

I’ve tried to put this but doesn’t work for all activities. It keeps going to home screen. I don’t know what can it be.

@Override
    public boolean onKeyDown(int keyCode, KeyEvent event) {
        if (keyCode == KeyEvent.KEYCODE_BACK) {
                finish();
            return true;
        }
        return super.onKeyDown(keyCode, event);
    }

I also tried with onBackPressed() method, but nothing. And also, instead of calling finish I tried with a new intent and calling the some activity explicity, but nothing too.

I can’t put all my activities here because are a lot.
But Here is one, and maybe if something works with this I can implement on others. Thanks.

public class MyActivity extends Activity {

    private ListView listview;
    private ImageView imgView;
    private Resources res;
    private Drawable transition;
    private SimpleCursorAdapter adapter;
    private DataHandlerDB handler;
    private SQLiteDatabase db;
    private OpenHelper helper;

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);          
        helper = new OpenHelper(this);
        db = helper.getWritableDatabase();
        setBasicContent();

    }

    @Override
    public void onStart() {

        super.onStart();
        helper = new OpenHelper(this);
        db = helper.getWritableDatabase();
        setBasicContent();

    }

    @Override
    public void onDestroy() {

        super.onDestroy();
        DataHandlerDB.selectTopCalls(this).close();
        db.close();
        helper.close();

    }

    @Override
    public void onPause() {

        super.onPause();

    }

    @Override
    public void onStop() {

        super.onStop();
        DataHandlerDB.selectTopCalls(this).close();
        db.close();
        helper.close();

    }

    @Override
    protected void onResume() {

        super.onResume();
        setBasicContent();

    }


    public void setBasicContent() {

        listview = (ListView) findViewById(R.id.list_view);

        Cursor c = DataHandlerDB.selectTopCalls(this);      

        c.moveToFirst();

        startManagingCursor(c);     

        adapter = new SimpleCursorAdapter(this, R.layout.list_item, c,
                new String[] { DataHandlerDB.CONTACT_NAME_COL,
                        DataHandlerDB.CONTACT_NUMBER_COL,
                        DataHandlerDB.CONTACT_DURATION_COL,
                        DataHandlerDB.CONTACT_DATE_COL }, new int[] {
                        R.id.contact_name, R.id.phone_number, R.id.duration,
                        R.id.date });       

        listview.setAdapter(adapter);
    }
}

Here is the activity that extends ActivityGroup its called like this:

tabHost.addTab(tabHost.newTabSpec("three").setIndicator("Filter Options", 
                res.getDrawable(R.drawable.filteroptionsiconfile))
                .setContent(new Intent(this, FilterOptionsGroup.class)));

FilterOptionsGroup.java

public class FilterOptionsGroup extends ActivityGroup {

    public static FilterOptionsGroup group;
    private ArrayList<View> history;

    @Override
    public void onCreate(Bundle savedInstanceState) {

        super.onCreate(savedInstanceState);
        this.history = new ArrayList<View>();
        group = this;

        View view = getLocalActivityManager().startActivity(
                "FilterOptions",
                new Intent(this, FilterOptions.class)
                        .addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP))
                .getDecorView();

        replaceView(view);

    }

    public void replaceView(View v) {
        // Adds the old one to history
        history.add(v);         
        // Changes this Groups View to the new View.
        setContentView(v);
    }

}
  • 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-23T09:42:57+00:00Added an answer on May 23, 2026 at 9:42 am

    If all of your activities are encapsulated within a tab host and they are all hosted in tabs then they are not really sitting in the stack. They are sitting within the foreground view which is the tab host screen and the back button will drop you to the previous app.

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

Sidebar

Related Questions

link Im having trouble converting the html entites into html characters, (&# 8217;) i
this is what i have right now Drawing an RSS feed into the php,
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I have this code: - (void)parser:(NSXMLParser *)parser foundCDATA:(NSData *)CDATABlock { NSString *someString = [[NSString
I have some data like this: 1 2 3 4 5 9 2 6
I have a text area in my form which accepts all possible characters from
Does anyone know how can I replace this 2 symbol below from the string
I have just tried to save a simple *.rtf file with some websites and
I ran into a problem. Wrote the following code snippet: teksti = teksti.Trim() teksti
I have a French site that I want to parse, but am running into

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.