Code example for ContextWrapper

Methods: setClass, bindService, startService

0
	public static RCCServiceToken bindToRCCService(Activity context, ServiceConnection callback) {
		Activity realActivity = context.getParent();
		if (realActivity == null) {
			realActivity = context;
		} 
		ContextWrapper cw = new ContextWrapper(realActivity);
		cw.startService(new Intent(cw, DlnaRemouteControlerService.class));
		RCCServiceBinder sb = new RCCServiceBinder(callback);
		if (cw.bindService((new Intent()).setClass(cw, DlnaRemouteControlerService.class), sb, 0)) {
			sRCCConnectionMap.put(cw, sb);
			return new RCCServiceToken(cw);
		} 
		Log.e(TAG, "Failed to bind to RCC service");
		return null; 
	} 
 
	public static void unbindFromRCCService(RCCServiceToken token) {
		if (token == null) {
			Log.e(TAG, "Trying to unbind with RCC null token");
			return; 
		}