0

My application have 3 tabs. In this one tab have multiple activities(means this tab have navigation to the child tabs). I used the startActivityforResult() in one child activity. But control never goes to onActivityResult() method. How to implement this. please can anybody help me.

code

public class Activity_1 extends Activity
{


public void onCreate(Bundle savedInstanceState) 
{
    super.onCreate(savedInstanceState);
    View contentView = LayoutInflater.from(getParent()).inflate(R.layout.static_search_filters, null);  
    setContentView(contentView);  

    states_tv = (TextView)findViewById(R.id.state);
    states_tv.setOnClickListener(states_etListener);        
}

private OnClickListener states_etListener = new View.OnClickListener()
{
    public void onClick(View v)
    {               
        Intent intent = new Intent(getParent(), RB_CategoriesMList.class);
        intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
        startActivityForResult(intent,GET_SEL_STATES_LIST);             
    }       
};

 protected void onActivityResult(int requestCode, int resultCode, Intent data) 
 {
      super.onActivityResult(requestCode, resultCode, data);    
      //I do some stuff here
 }
}   

//Activity_2

public class RB_CategoriesMList extends ListActivity
{



public Button sbtn;   

@Override
public void onCreate(Bundle savedInstanceState) 
{
    super.onCreate(savedInstanceState);
    setContentView(R.layout.categories_list);           

    sbtn =(Button)findViewById(R.id.submit_categories);
    sbtn.setOnClickListener(sbtn_listener);
}       

private OnClickListener sbtn_listener = new View.OnClickListener()
{
    public void onClick(View v)
    {
        Intent state_intent = getIntent();              
        state_intent.putExtra("selected_states", "");                                       
        setResult(RESULT_OK,state_intent);
        finish();           
    }       
};  
}   
Vikram
  • 8,235
  • 33
  • 47
naresh
  • 10,332
  • 25
  • 81
  • 124
  • http://stackoverflow.com/questions/1306689/launching-activities-within-a-tab-in-android ... anyway you shouldn't do this ... it seams like your UI is not well designed for Android – Selvin Apr 13 '12 at 12:39

2 Answers2

0

Dont call

  super.onActivityResult(requestCode, resultCode, data);    

When you receive the onActivityResult, check if the request code is your and then do your stuff. In the other cases you should call the super.

So:

protected void onActivityResult(int requestCode, int resultCode, Intent data) 
{
    if (requestCode == GET_SEL_STATES_LIST) {
        // Do your stuff
    } else {
        super.onActivityResult(requestCode, resultCode, data);    
    }
}
Ion Aalbers
  • 7,830
  • 3
  • 37
  • 50
0
getParent().startActivityForResult(yourNewIntent, yourResult);