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