Code example for ContextWrapper

Methods: bindService, startService

		return bindToService(context, null);
	public static ServiceToken bindToService(Context context, ServiceConnection callback) {
		ContextWrapper cw = new ContextWrapper(context);
		cw.startService(new Intent(cw, MusicPlaybackService.class));
		ServiceBinder sb = new ServiceBinder(callback);
		if (cw.bindService(new Intent(cw, MusicPlaybackService.class), sb, 0)) {
			sConnectionMap.put(cw, sb);
			return new ServiceToken(cw);
		Log.e("Music", "Failed to bind to service");
		return null; 
	public static void unbindFromService(ServiceToken token) {
		if (token == null) {
			Log.e(LOGTAG, "Trying to unbind with null token");