/** * Interface used to interact with the actual instance of MessageManager. * This inteface allows will be the type of the reference that will point * to the actual MessageMessenger, which will be loaded dynamically. * @author steff * */ public abstract class MessageManager { /** Request code used to identify mail messages.*/ public final static int FOR_MAIL = 0x3689; /** Request code used to identify SMS messages.*/ public final static int FOR_SMS = 0x3698; /** * Start an activity inside the given context. It will allow to pickup a contact * and will be given an intent code to get contact pick up. * *@param the request code. Has to be a constant : FOR_MAIL or FOR_SMS */ public abstract void pickupContact(int code);//met /** * Start an activity inside the given context. It will allow to pickup a contact * and will be given an intent code to get contact pick up. * *@param the request code. Has to be a constant : FOR_MAIL or FOR_SMS */ public abstract void sendMessage(int code, Intent data, final String body);//met /** * Static methode used as in factory design pattern to create an instance * of messageManager. Here it is combined with the singleton pattern to * get an instance of an inherited class that is supported by current android SDK. * This singleton will be created bu reflexion. * @param activity the activity that needs messaging capabilities. * @return an instance of an inherited class that is supported by current android SDK or null, if not found. */ public static MessageManager getInstance( Activity activity ) { MessageManager instance = null; try { Class<? extends MessageManager> messageManagerClass = (Class<? extends MessageManager>) activity.getClassLoader().loadClass( "ca.qc.webalterpraxis.cinedroid.message.MessageManagerSDK7" ); Method singletonMethod = messageManagerClass.getMethod("getInstance", Activity.class ); instance = (MessageManager) singletonMethod.invoke( null , activity); } catch (Throwable e) { Log.e( "CinemadroidMain", "Impossible to get an instance of class MessageManagerSDK7",e ); }//met return instance; }//met }//interface