protected App() { // starting a service like this is blocking, so we want to do it on a background thread new Task(() => { // start our main service Log.Debug(logTag, "Calling StartService"); Android.App.Application.Context.StartService(new Intent(Android.App.Application.Context, typeof(LocationService))); // create a new service connection so we can get a binder to the service this.locationServiceConnection = new LocationServiceConnection(null); // this event will fire when the Service connectin in the OnServiceConnected call this.locationServiceConnection.ServiceConnected += (object sender, ServiceConnectedEventArgs e) => { Log.Debug(logTag, "Service Connected"); // we will use this event to notify MainActivity when to start updating the UI this.LocationServiceConnected(this, e); }; // bind our service (Android goes and finds the running service by type, and puts a reference // on the binder to that service) // The Intent tells the OS where to find our Service (the Context) and the Type of Service // we're looking for (LocationService) Intent locationServiceIntent = new Intent(Android.App.Application.Context, typeof(LocationService)); Log.Debug(logTag, "Calling service binding"); // Finally, we can bind to the Service using our Intent and the ServiceConnection we // created in a previous step. Android.App.Application.Context.BindService(locationServiceIntent, locationServiceConnection, Bind.AutoCreate); }).Start(); }
protected App() { _locationServiceConnection = new LocationServiceConnection(null); _locationServiceConnection.ServiceConnected += (s, e) => { Log.Debug(logTag, "Service Connected"); LocationServiceConnection(this, e); }; }
protected override void OnStart() { base.OnStart(); if (locationServiceConnection == null) { locationServiceConnection = new LocationServiceConnection(this); } // BindToService(); }
protected AppLocation() { // create a new service connection so we can get a binder to the service locationServiceConnection = new LocationServiceConnection(null); // this event will fire when the Service connectin in the OnServiceConnected call locationServiceConnection.ServiceConnected += (sender, e) => LocationServiceConnected(this, e); }
protected App_Foreground() { // create a new service connection so we can get a binder to the service locationServiceConnection = new LocationServiceConnection(null); // this event will fire when the Service connectin in the OnServiceConnected call locationServiceConnection.ServiceConnected += (object sender, ServiceConnectedEventArgs e) => { Log.Debug(logTag, "Service Connected"); // we will use this event to notify MainActivity when to start updating the UI this.LocationServiceConnected(this, e); }; }
protected LocationHandler() { // create a new service connection so we can get a binder to the service locationServiceConnection = new LocationServiceConnection(null); // this event will fire when the Service connecting in the OnServiceConnected call locationServiceConnection.ServiceConnected += (sender, e) => { Log.Debug(TAG, "Service Connected"); // we will use this event to notify MainActivity when to start updating the UI LocationServiceConnected(this, e); }; }
public AndroidServiceHelper() { // create a new service connection so we can get a binder to the service locationServiceConnection = new LocationServiceConnection(null); locationServiceConnection.ServiceConnected += (sender, e) => { Log.Debug(logTag, "Service Connected"); // we will use this event to notify MainActivity when to start updating the UI LocationServiceConnected(this, e); }; context = global::Android.App.Application.Context; isOn = false; }
protected App() { new Task(() => { Log.Debug(logTag, "Calling StartService"); Android.App.Application.Context.StartService(new Intent(Android.App.Application.Context, typeof(LocationService))); this.locationServiceConnection = new LocationServiceConnection(null); this.locationServiceConnection.ServiceConnected += (object sender, ServiceConnectedEventArgs e) => { Log.Debug(logTag, "Service Connected"); this.LocationServiceConnected(this, e); }; Intent locationServiceIntent = new Intent(Android.App.Application.Context, typeof(LocationService)); Log.Debug(logTag, "Calling service binding"); Android.App.Application.Context.BindService(locationServiceIntent, locationServiceConnection, Bind.AutoCreate); }).Start(); }
protected override void OnStart() { base.OnStart(); if (LocationServiceConnection == null) { LocationServiceConnection = new LocationServiceConnection(this); } var serviceToStart = new Intent(this, typeof(LocationService)); BindService(serviceToStart, LocationServiceConnection, Bind.AutoCreate); Console.WriteLine(); Console.WriteLine("STARTED"); Console.WriteLine(); }