将事件侦听器添加到特定的Activity

时间:2016-08-21 11:16:22

标签: android events event-handling

在我的GcmIntentService中收到GCM Intent后,我正在构建推送通知,我必须将特定的Activity设置为EventListener。

public class GcmIntentService extends IntentService {

    @Override
    protected void onHandleIntent(final Intent intent) {
        //This code gets triggered, what to add here 
        // to make SomeActivity's onEvent get triggered
    }
}


public interface EventListener {
    int onEvent(Event event);
}

public class SomeActivity extends Activity implements EventListener {

    @Override
    public int onEvent(Event event) {

    }
}