I am using this example to lean about AIDL:
https://github.com/xamarin/monodroid-samples/tree/master/AIDLDemo/AIDLDemo
The example is fairly simple, and it runs on Android 4.4, but I must run it on Android 9+. So I modified it a little.
For example, the addition of the package name to the intent for the BindingService in Activity1.cs:
private void InitService ()
{
_serviceConnection = new AdditionServiceConnection (this);
var additionServiceIntent = new Intent ("com.xamarin.additionservice");
additionServiceIntent.SetPackage("AIDLDemo.AIDLDemo"); //<--------------- Added it
_serviceConnection = new AdditionServiceConnection (this);
ApplicationContext.BindService (additionServiceIntent, _serviceConnection, Bind.AutoCreate);
Log.Debug (Tag, "Service initialized");
}
I want to add some attributes to the service:
In AndroidService.cs class, there were no attributes for the Service, I added the following:
[Service(Name = "Xamarin.AidlDemo.AdditionService",
Exported = true,
Enabled = true,
Process = ":mf_background_process")]
But, once I add the last attribute, Process, the app won't work anymore, it throws the following error:
The AdditionService is not bound
It is an error caught in the Activity1.cs class, while checking if the binding was successful. This is caused because I added the Process attribute in the Service.
Can you help me solve this issue? Why won't the service bind anymore while it's in another thread?
Thank you for your time.