本文整理汇总了Java中com.google.ipc.invalidation.external.client.android.service.ListenerService类的典型用法代码示例。如果您正苦于以下问题:Java ListenerService类的具体用法?Java ListenerService怎么用?Java ListenerService使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ListenerService类属于com.google.ipc.invalidation.external.client.android.service包,在下文中一共展示了ListenerService类的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: sendEvent
import com.google.ipc.invalidation.external.client.android.service.ListenerService; //导入依赖的package包/类
@Override
public void sendEvent(final Bundle eventBundle) {
synchronized (LOCK) {
// Retrive info for that target client
String clientKey = eventBundle.getString(Parameter.CLIENT);
ClientState state = clientMap.get(clientKey);
Preconditions.checkNotNull(state, "No state for %s in %s", clientKey, clientMap.keySet());
// Bind to the listener associated with the client and send the event
ListenerBinder binder = new ListenerBinder(getBaseContext(), state.eventIntent,
InvalidationTestListener.class.getName());
binder.runWhenBound(new BoundWork<ListenerService>() {
@Override
public void run(ListenerService service) {
InvalidationTestService.this.sendEvent(service, new Event(eventBundle));
}
});
// Will happen after the runWhenBound invokes the receiver. Could also be done inside
// the receiver.
binder.release();
}
}
示例2: sendEvent
import com.google.ipc.invalidation.external.client.android.service.ListenerService; //导入依赖的package包/类
/**
* Send event messages to application clients and provides common processing of the response.
*/
private void sendEvent(final Event event) {
binder.runWhenBound(new BoundWork<ListenerService>() {
@Override
public void run(ListenerService listenerService) {
logger.fine("Sending %s event to %s", event.getAction(), clientKey);
service.sendEvent(listenerService, event);
}
});
}
示例3: sendEvent
import com.google.ipc.invalidation.external.client.android.service.ListenerService; //导入依赖的package包/类
/**
* Send event messages to application clients and provides common processing
* of the response.
*/
protected void sendEvent(ListenerService listenerService, Event event) {
try {
logger.fine("Sending %s event", event.getAction());
Bundle responseBundle = new Bundle();
listenerService.handleEvent(event.getBundle(), responseBundle);
// Wrap the response bundle and throw on any failure from the client
Response response = new Response(responseBundle);
response.warnOnFailure();
} catch (RemoteException exception) {
logger.severe("Unable to send event", exception);
throw new RuntimeException("Unable to send event", exception);
}
}