AngeloS
AngeloS

Reputation: 5586

How can I call a non-static method in a child Activity of an ActivityGroup from the ActivityGroup?

I think the easiest way to ask the question would be to demonstrate how my current workflow is set up first:

  1. There is a TabHost that has an ActivityGroup as one of its tabs
  2. That ActivityGroup as an Activity in it that calls an external service that I have no control over.
  3. The External Service has a callback function that kicks off onActivityResult in the ActivityGroup and NOT in the Activity that called the Service. This is because in order to have even have the onActivityResult fire, I had to call getParent().startActivityForResult(

The problem is that I want 'stuff' to happen in the Activity that called the External Service (e.g. an Alert Dialog, a web service call etc).

So, how can a call a non-static method in the child Activity from the ActivityGroup? Is this even possible?

Upvotes: 0

Views: 435

Answers (1)

AngeloS
AngeloS

Reputation: 5586

I figured it out. In the ActivityGroup's onActivityResult I got the current activity using getLocalActivityManager().getCurrentActivity()and edit: cast it as the class I need, then called the non-static method on it:

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


        FooChildActivity foo = (FooChildActivity)getLocalActivityManager().getCurrentActivity();
        foo.barNonStaticMethod(requestCode, resultCode, data);

 }

Upvotes: 1

Related Questions