android: ending activity from tab
        Posted  
        
            by 
                Jin
            
        on Stack Overflow
        
        See other posts from Stack Overflow
        
            or by Jin
        
        
        
        Published on 2011-01-15T11:50:14Z
        Indexed on 
            2011/01/15
            11:53 UTC
        
        
        Read the original article
        Hit count: 222
        
I have 3 classes, let's call them 1, 2, and 3.
Class 1 extends TabActivity and organizes the whole tab thing, Class 2 and 3 are just two separate tabs each with some lines of text. I call Class 1 from another activity using startActivityForResult.
I then added an optionsMenu in class 2, and when user clicks the optionMenu, the following code is carried out:
@Override
    public boolean onMenuItemSelected(int featureId, MenuItem item) {
        Intent i = new Intent();
        switch(item.getItemId()) {
            case Result.NEXT_ID:
                i.putExtra(Result.PAGE_REQUEST, NEXT);
                setResult(RESULT_OK, i);
                finish();
                break;
            case Result.PREV_ID:
                i.putExtra(Result.PAGE_REQUEST, PREV);
                setResult(RESULT_OK, i);
                finish();
        }
        return super.onMenuItemSelected(featureId, item);
    }
In my parent class (the class that called 1 to begin with), in its onActivityResult function, I want to get the data from the extras. However, the intent is always null, and I can't figure out why.
When I call finish() on class 2, is it calling some other function in class 1? Do I have to transfer the intent data somehow?
© Stack Overflow or respective owner