private void Btnstophybridservice_Click(object sender, System.EventArgs e)
        {
            if (null == serviceConnection)
            {
                Toast.MakeText(this, "There is no connection", ToastLength.Long).Show();
                return;
            }

            UnbindService(serviceConnection);
            serviceConnection = null;
            StopService(new Intent(this, typeof(HybridService)));
        }
        private void Btnstarthybridservice_Click(object sender, System.EventArgs e)
        {
            if (null != serviceConnection)
            {
                Toast.MakeText(this, "There is a connection already", ToastLength.Long).Show();
                return;
            }

            Intent startIntent = new Intent(this, typeof(HybridService));

            StartService(startIntent);

            serviceConnection = new BoundServiceConnection();

            //StartService(new Intent(this, typeof(HybridService)));
            BindService((new Intent(this, typeof(HybridService))), serviceConnection, Bind.AutoCreate);

            //ScheduleStockUpdates();
        }
Exemplo n.º 3
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            Logger.Information("OnCreate()", nameof(MainActivity));

            var width   = Resources.DisplayMetrics.WidthPixels;
            var height  = Resources.DisplayMetrics.HeightPixels;
            var density = Resources.DisplayMetrics.Density;

            App.ScreenWidth  = (width - 0.5f) / density;
            App.ScreenHeight = (height - 0.5f) / density;


            try
            {
                //Singleton.Services.GetService<ICurrentContext>().Context = this;

                //Singleton.Services.UnRegisterService<IResumeSupportService>();
                //Singleton.Services.RegisterService<IResumeSupportService>(this);
                //Singleton.Services.UnRegisterService<IStub>();

                //Singleton.Services.RegisterService<IStub>(this);

                TabLayoutResource = Resource.Layout.Tabbar;
                ToolbarResource   = Resource.Layout.Toolbar;

                Forms.Init(this, savedInstanceState);

                base.OnCreate(savedInstanceState);
                LoadApplication(new App());

                if (_serviceConnection == null)
                {
                    _serviceConnection = new BoundServiceConnection();
                }
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
                throw;
            }
        }
 public MyBoundServiceBinder(BoundServiceConnection service)
 {
     this.service = service;
 }