Skip to content Skip to sidebar Skip to footer

Retrieving The Component Name Of A Service Defined In Another Xamarin Application

I'm currently implementing an Android Service which is to be consumed by another application of a partner company. They implement the frontend GUI, we do the business logic inside

Solution 1:

The Application with the Service:

Package Name = com.sushihangover.androidservice

[Service(Name="com.sushihangover.androidservice.MyMostAmazingService", Exported = true)]
[IntentFilter(new String[] { "myservice" }, Categories = new[] { Intent.CategoryDefault })]
publicclassPsiServiceHost : Service
{
    publicoverride IBinder OnBind(Intent intent)
    {
        returnnull;
    }
    publicoverride StartCommandResult OnStartCommand(Intent intent, StartCommandFlags flags, int startId)
    {
        Log.Debug("SO", "MyMostAmazingService Has Been Started");
        returnbase.OnStartCommand(intent, flags, startId);
    }
}

The other application starting MyMostAmazingService:

var intent = new Intent();
// Package name first, Service Class Name Second
intent.SetClassName("com.sushihangover.androidservice", "com.sushihangover.androidservice.MyMostAmazingService");
StartService(intent);

Post a Comment for "Retrieving The Component Name Of A Service Defined In Another Xamarin Application"