Domanda

the on ActivityResult() method,written in a childActivity never invoked

My TabGrpActivity extends ActivityGroup.

public class TabGroupActivity extends ActivityGroup 

{ private ArrayListmIdList;

@Override
protected void onCreate(Bundle savedInstanceState) 
{
    // TODO Auto-generated method stub
    super.onCreate(savedInstanceState);

    if(mIdList==null)
        mIdList = new ArrayList<String>();
    obj = new ScheduleView();
    startChildActivity("Activity1", new Intent(this,Activity1.class));
}


public void startChildActivity(String Id,Intent intent)
{
    Window window = getLocalActivityManager().startActivity(Id, 
            intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP));
    if(window!=null)
    {
        mIdList.add(Id);
        setContentView(window.getDecorView());
    }
}

in my Activity1(a child activity) call a another activity using startActivityForresult().. the code is given below.

mybund.putString("event", obj_rowitem.getevent());
Intent schedule = new Intent(getApplicationContext(), Activity2.class);
schedule.putExtras(mybund);
startActivityForResult(schedule, req_code);

and i alsow wrote a onActivityResult method in Activity1, the code given below

@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data)
{

    year = data.getExtras().getInt("year");
    month=data.getExtras().getInt("month");
    date=data.getExtras().getInt("date");
    String getdate=year+"-"+month+"-"+date;
    readschedules(getdate);
    rowitems=getdata(getdate);
    listview.setAdapter(new CustomView(getApplicationContext(), rowitems));

}

the one thing is that i call the Activity2 as a simple activity its not a child activity...

here i have the problem is that... after calling the setResult() in the Activity2 where the control will go....

i didnt understand the life cylcle ActivityGroup..

È stato utile?

Soluzione

You should use the activity context instead of the application context, that way it will return the result to the right activity. So:

Intent schedule = new Intent(this, Activity2.class);

or:

Intent schedule = new Intent(Activity1.this, Activity2.class)

For more info read about the different contexts.

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top