Throwing an event in an Application, handling it in an Activity


Last Updated:

  1. KingLeigh

    KingLeigh New Member This Topic's Starter

    Joined:
    May 17, 2010
    Messages:
    1
    Likes Received:
    0
    I'm building my first application which consists of a number of Activities and a centralised Application which holds larger objects and variables which are accessed throughout the application.

    I am looking for a way to 'throw' events at the Application level, and handle them at the Activity level.

    Specifically, I have an object held in Application, which has a Date member variable. When the date/time is met, I need an event to be thrown. The user could be viewing any of the screens at this time, and the event will be handled differently depending on which screen they are on.

    I have tried solving this using Handlers and Broadcasts, but have been unsuccessful so far. All examples have the 'sender' and the 'receiver' in the same class, I run into problems when trying to separate them.

    If anyone can give any advice on what I should be using to achieve this, it would be much appreciated. In other environments, I would do this by having the Application cause an Event, and Handling this event in each of the activities. Is something like this possible?

    Thanks in advance, I hope that is clear enough.
     

    Advertisement

Share This Page

Loading...