private void Initialize(Context c) { context = c; isConnected = false; binder = null; i = new Intent(context, typeof(CountService)); isDead = false; context.StartService(i); context.BindService(i, this, Bind.AutoCreate); Toast.MakeText(context, "Bind Service", ToastLength.Short).Show(); SetBackgroundColor(Color.White); color = new Paint(); color.SetARGB(255, 255, 255, 255); textPaint = new Paint(); textPaint.TextSize = 90; textPaint.SetARGB(50, 50, 50, 50); jamvPlayer = new JamvPlayer(BitmapFactory.DecodeResource(Resources, Resource.Drawable.Imagem_Happy), context); jamvPlayerHalfandHalf = new JamvPlayer(BitmapFactory.DecodeResource(Resources, Resource.Drawable.Imagem_MeioAMeio), context); JanvMorreu = new JamvPlayer(BitmapFactory.DecodeResource(Resources, Resource.Drawable.KO), context); BotaoComida = new Boton(BitmapFactory.DecodeResource(Resources, Resource.Drawable.Steak), context, 50, 500, 200, 200); BotaoAgua = new Boton(BitmapFactory.DecodeResource(Resources, Resource.Drawable.Agua), context, 300, 439, 300, 300); handler = new Handler(); FoodCount = new CountService(); handler.Post(this); }
public void OnServiceDisconnected(ComponentName name) { count = null; binder = null; isConnected = false; Toast.MakeText(this.context, "Service Disconnected", ToastLength.Short).Show(); }
private void UnbindConnection() { if (binder != null) { binder = null; count = null; context.UnbindService(this); Toast.MakeText(this.context, "Unbind Service", ToastLength.Short).Show(); } else { Toast.MakeText(this.context, "Service is already unbind", ToastLength.Short).Show(); } }
public void OnServiceConnected(ComponentName name, IBinder service) { binder = (CountBinder)service; isConnected = binder != null; if (isConnected) { count = (Count)binder.Service; Toast.MakeText(this.context, "Service Connected", ToastLength.Short).Show(); } else { count = null; Toast.MakeText(this.context, "Service Not Connected", ToastLength.Short).Show(); } }