public void unbindAppService() { AppLog.d(context, "AppServiceConnection: unbindAppService"); // detach our existing connection context.unbindService(serviceConnection); appService = null; }
@Override public void onServiceConnected(ComponentName className, IBinder service) { AppLog.d(context, "ServiceConnection: onServiceConnected " + this.toString()); appService = ((AppService.LocalBinder) service).getService(); // executing activity's callback new Handler().post(runnable); }
public void bindAppService() { if (appService != null) { // return; } Log.v(Constants.TAG, "AppServiceConnection: bindAppService"); Intent i = new Intent(context, AppService.class); if (!context.bindService(i, serviceConnection, 0)) { Toast.makeText(context, "Can't connect to GPS service", Toast.LENGTH_SHORT).show(); AppLog.d(context, "bindAppService: Can't connect to GPS service"); } }
@Override public void onServiceDisconnected(ComponentName className) { AppLog.d(context, "ServiceConnection: onServiceDisconnected"); }