In Xamarin we have functionality to build app using C# and other Visual Studio supportive languages.
We can build apps by implementing services into it.
For using and implementing services we can use interfaces and classes that contains the property and methods to invoke and handle user and system defined services.
In android app we can do it by implementing interface named IBinder
And we bind this service with the help of intent.
System.Threading.Timer _timer;
public override void OnStart (Android.Content.Intent intent, int startId)
{
base.OnStart (intent, startId);
Log.Debug ("My Service", "SimpleService started");
}
public override void OnDestroy ()
{
base.OnDestroy ();
_timer.Dispose ();
Log.Debug ("My Service", "SimpleService stopped");
}
public void DoStuff ()
{
_timer = new System.Threading.Timer ((o) => {
Log.Debug ("SimpleService", "hello from simple service");
}, null, 0, 4000);
}
public override Android.OS.IBinder OnBind (Android.Content.Intent intent)
{
throw new NotImplementedException ();
}
0 Comment(s)