AeroGear Android Library 1.2.1

org.jboss.aerogear.android.unifiedpush
Class Registrations

java.lang.Object
  extended by org.jboss.aerogear.android.unifiedpush.Registrations

public class Registrations
extends Object

This is the factory and accessors for PushRegistrars


Constructor Summary
Registrations()
           
Registrations(PushRegistrarFactory factory)
           
 
Method Summary
 PushRegistrar get(String name)
          Recalls a PushRegister instance which was created with push(java.lang.String, org.jboss.aerogear.android.unifiedpush.PushConfig).
protected static void notifyHandlers(android.content.Context context, android.content.Intent message)
          This will deliver an intent to all registered handlers.
static void notifyHandlers(android.content.Context context, android.content.Intent message, MessageHandler defaultHandler)
          This will deliver an intent to all registered handlers.
 PushRegistrar push(String name, PushConfig config)
          This method will try to build a PuserRegistrar based on the values in the configuration bean.
static void registerBackgroundThreadHandler(MessageHandler handler)
          When a push message is received, all background thread handlers will be notified on a non UI thread.
static void registerMainThreadHandler(MessageHandler handler)
          When a push message is received, all main thread handlers will be notified on the main(UI) thread.
static void unregisterBackgroundThreadHandler(MessageHandler handler)
          This will remove the given handler from the collection of background thread handlers.
static void unregisterMainThreadHandler(MessageHandler handler)
          This will remove the given handler from the collection of main thread handlers.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Registrations

public Registrations()

Registrations

public Registrations(PushRegistrarFactory factory)
Method Detail

push

public PushRegistrar push(String name,
                          PushConfig config)
This method will try to build a PuserRegistrar based on the values in the configuration bean. It will store a reference to the Registrar which can be recalled using get(java.lang.String) and passing in the name parameter.

Parameters:
name - the name which will be used to look up the registrar later
config - a configuration bean.
Returns:
a PushRegistration for config
Throws:
IllegalArgumentException - is config.type is not a supported type

get

public PushRegistrar get(String name)
Recalls a PushRegister instance which was created with push(java.lang.String, org.jboss.aerogear.android.unifiedpush.PushConfig).

Parameters:
name - the name parameter to look up
Returns:
a PushRegistration or null if none is found.

registerMainThreadHandler

public static void registerMainThreadHandler(MessageHandler handler)
When a push message is received, all main thread handlers will be notified on the main(UI) thread. This is very convenient for Activities and Fragments.

Parameters:
handler - a handler to added to the list of handlers to be notified.

registerBackgroundThreadHandler

public static void registerBackgroundThreadHandler(MessageHandler handler)
When a push message is received, all background thread handlers will be notified on a non UI thread. This should be used by classes which need to update internal state or preform some action which doesn't change the UI.

Parameters:
handler - a handler to added to the list of handlers to be notified.

unregisterMainThreadHandler

public static void unregisterMainThreadHandler(MessageHandler handler)
This will remove the given handler from the collection of main thread handlers. This MUST be called when a Fragment or activity is backgrounded via onPause.

Parameters:
handler -

unregisterBackgroundThreadHandler

public static void unregisterBackgroundThreadHandler(MessageHandler handler)
This will remove the given handler from the collection of background thread handlers.

Parameters:
handler -

notifyHandlers

public static void notifyHandlers(android.content.Context context,
                                  android.content.Intent message,
                                  MessageHandler defaultHandler)
This will deliver an intent to all registered handlers. See PushConstants for information on how messages will be routed.

Parameters:
context - the application's context
message - the message to pass
defaultHandler - a default handler is a handler which will be called if there are no other handlers registered. May be null

notifyHandlers

protected static void notifyHandlers(android.content.Context context,
                                     android.content.Intent message)
This will deliver an intent to all registered handlers. Currently it is GCM centric, but this will be changed in the future. See: AGDROID-84

Parameters:
context - the application's context
message - the message to pass

AeroGear Android Library 1.2.1

Copyright © 2013 JBoss by Red Hat. All Rights Reserved.