Your service may not be null, because service binding is an asynchronous method, so instead of checking the availability of your service even after calling the binding method, you should do this in your implementation of connecting to the service, for example:
private ServiceConnection service_conn=new ServiceConnection(){ public void onServiceConnected(ComponentName className, IBinder service) { LocalBinder binder=(LocalBinder)service; playing_service=binder.getService(); if(playing_service != null){ Log.i("service-bind", "Service is bonded successfully!");
source share