Code example for ContextWrapper

Methods: bindServicestartService

		return bindService(context, intent, null);
	public static ServiceToken bindService(final Context context, final Intent intent, final ServiceConnection callback) {
		if (context == null || intent == null) return null;
		final ContextWrapper cw = new ContextWrapper(context);
		final ComponentName cn = cw.startService(intent);
		if (cn != null) {
			final ServiceUtils.ServiceBinder sb = new ServiceBinder(callback);
			if (cw.bindService(intent, sb, 0)) {
				sConnectionMap.put(cw, sb);
				return new ServiceToken(cw);
		Log.e(LOGTAG, "Failed to bind to service");
		return null; 
	public static void unbindService(final ServiceToken token) {
		if (token == null) return;