コード例 #1
0
 public void OnServiceDisconnected(ComponentName name)
 {
     Log.Debug(TAG, $"OnServiceDisconnected {name.ClassName}");
     IsConnected = false;
     Binder      = null;
     timestampActivity.UpdateUiForUnboundService();
 }
コード例 #2
0
        /// <summary>
        /// 有客户端(某个Activity)连接上时会调用此方法
        /// </summary>
        /// <param name="name"></param>
        /// <param name="service"></param>
        public void OnServiceConnected(ComponentName name, IBinder service)
        {
            Binder      = service as TimestampBinder;
            IsConnected = this.Binder != null;

            string message = "onServiceConnected - ";

            Log.Debug(TAG, $"OnServiceConnected {name.ClassName}");

            if (IsConnected)
            {
                message = message + " bound to service " + name.ClassName; //服务的名字
                timestampActivity.UpdateUiForBoundService();
            }
            else
            {
                message = message + " not bound to service " + name.ClassName;
                timestampActivity.UpdateUiForUnboundService();
            }

            Log.Info(TAG, message);
            timestampActivity.timestampMessageTextView.Text = message;
        }
コード例 #3
0
 /// <summary>
 /// 绑定客户端TimestampActivity
 /// </summary>
 /// <param name="activity"></param>
 public TimestampServiceConnection(TimestampActivity activity)
 {
     IsConnected       = false;
     Binder            = null;
     timestampActivity = activity;
 }