sPFLib/src/main/java/it/polimi/spf/lib/Component.java
private static <C extends Component<C, I>, I extends IInterface> void bindToService(final Context context, final Descriptor<C, I> descriptor, final ConnectionCallback<C> callback) {

		Intent intent = new Intent();
		intent.setComponent(SPFInfo.getSPFServiceComponentName());
		intent.setAction(descriptor.getActionName());

		ServiceConnection connection = new ServiceConnection() {

			@Override
			public void onServiceConnected(ComponentName name, IBinder binder) {
				I service = descriptor.castInterface(binder);
				C instance = descriptor.createInstance(context, service, this, callback);
				callback.onServiceReady(instance);
			}

			@Override
			public void onServiceDisconnected(ComponentName name) {
				callback.onDisconnect();
			}
		};

		if (!context.bindService(intent, connection, Context.BIND_AUTO_CREATE)) {
			callback.onError(new SPFError(SPFError.SPF_NOT_INSTALLED_ERROR_CODE));
		}
	}
private static <C extends Component<C, I>, I extends IInterface> void bindToService(final Context context, final Descriptor<C, I> descriptor, final ConnectionCallback<C> callback) {

		Intent intent = new Intent();
		intent.setComponent(SPFInfo.getSPFServiceComponentName());
		intent.setAction(descriptor.getActionName());

		ServiceConnection connection = new ServiceConnection() {

			@Override
			public void onServiceConnected(ComponentName name, IBinder binder) {
				I service = descriptor.castInterface(binder);
				C instance = descriptor.createInstance(context, service, this, callback);
				callback.onServiceReady(instance);
			}

			@Override
			public void onServiceDisconnected(ComponentName name) {
				callback.onDisconnect();
			}
		};

		if (!context.bindService(intent, connection, Context.BIND_AUTO_CREATE)) {
			callback.onError(new SPFError(SPFError.SPF_NOT_INSTALLED_ERROR_CODE));
		}
	}
Performs the binding to the remote service

@param context
- the context used to bind to the service
@param descriptor
- the {@link Descriptor} to handle the service
@param callback
- the callback to notify of the service availability