public void OnServiceDisconnected(ComponentName name) { counter = null; binder = null; isConnected = false; Toast.MakeText(this, "Service Disconnected", ToastLength.Short).Show(); }
private void UnbindConnection() { if (binder != null) { binder = null; counter = null; UnbindService(this); Toast.MakeText(this, "Unbind Service", ToastLength.Short).Show(); } else { Toast.MakeText(this, "Service is already unbind", ToastLength.Short).Show(); } }
protected override void OnCreate(Bundle savedInstanceState) { base.OnCreate(savedInstanceState); SetContentView(Resource.Layout.bind_service); isConnected = false; binder = null; Button buttonStartBind = (Button)FindViewById(Resource.Id.buttonStartBind); Button buttonStopBind = (Button)FindViewById(Resource.Id.buttonStopBind); Button buttonGetCounter = (Button)FindViewById(Resource.Id.buttonGetCount); buttonStartBind.Click += OnButtonStartBindClicked; buttonStopBind.Click += OnButtonStopBindClicked; buttonGetCounter.Click += OnButtonGetCounterClicked; }
public void OnServiceConnected(ComponentName name, IBinder service) { binder = (CountBinder)service; isConnected = binder != null; if (isConnected) { counter = binder.Service; Toast.MakeText(this, "Service Connected", ToastLength.Short).Show(); } else { counter = null; Toast.MakeText(this, "Service Not Connected", ToastLength.Short).Show(); } }