tags:

views:

28

answers:

0

I have a class A which extends TabActivity and creates Activities B, C and D as tabs in its onCreate() function. Also, class A initializes another service handler class S which is responsible for establishing a connection to a service and implementing callback handlers for the service. Any of the Activities B, C and D should be able to receive events from the service and update accordingly. If I receive any event in class S from the the service then I want to call a function in Activity B which would be responsible to update the UI elements in Activity B based on the event received. You can assume that the user is in Activity B when the event arrives.

Can I call an activity function like the following in the stub handler for the callback in my class S -

   private Callback mEventListener = new OperationCallback.Stub()
{
   @Override
   public void handleOperationEvent(Payload payload)

   {
      B objB = new B();   // Is this valid? Since B is an activity.
      B.postEventToHandler(payload);  // postEventToHandler() is a method inside B

   }
};

Let me know I am doing the right thing to achieve what I want. Also, let me know if you need more clarification.