[mono-android] Reference to Service Class started with	StartService
    Jonathan Pryor 
    jonp at xamarin.com
       
    Wed Jan  4 13:23:31 EST 2012
    
    
  
On Dec 22, 2011, at 2:58 PM, devbuzz wrote:
> If I instantiate a Service class using StartService() like this:
> 
> StartService(new Intent(this, typeof(DBT.ServiceManager)));
> 
> how do I get a reference to the class?
If DBT.ServiceManager is a type within your application (which it should be for `typeof` to work), then just code around it: add code to your ServiceManager constructor storing the Service instance into a global variable "somewhere."
If it's not a type within your application, you're out of luck: there's no way (afaik) to obtain an instance of the Service class, especially since it lives in a different process and you'd need to use IPC to communicate with it anyway. This is where aidl and interfaces come in...
 - Jon
    
    
More information about the Monodroid
mailing list