Exemplo n.º 1
0
        public void OnServiceDisconnected(ComponentName name)
        {
            counter     = null;
            binder      = null;
            isConnected = false;

            Toast.MakeText(this, "Service Disconnected", ToastLength.Short).Show();
        }
Exemplo n.º 2
0
 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();
     }
 }
Exemplo n.º 3
0
        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;
        }
Exemplo n.º 4
0
        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();
            }
        }