Any one have an example of a bound service in Mono for Android. I am by no
means an expert at services but this looks pretty straightforward. My
BindService call always returns false and the OnBind method of the service
never gets called.
Ultimately what I am trying to do is use a Messenger to allow my C# service
to communicate with my GoogleMaps Activity (obviously written in Java).
Anythoughts on this approach?
Thanks
Dave Goughnour
Here is my test service:
[Service]
public class BoundService : Service
{
public class LocalBinder : Binder
{
}
private LocalBinder _binder = new LocalBinder();
public override void OnCreate()
{
base.OnCreate();
}
public override void OnStart(Intent intent, int startId)
{
base.OnStart(intent, startId);
}
public override StartCommandResult OnStartCommand(Intent intent,
StartCommandFlags flags, int startId)
{
return base.OnStartCommand(intent, flags, startId);
}
public override IBinder OnBind(Intent intent)
{
return _binder;
}
}
Here is my implementation of IServiceConnection
public class IMDSSConnection : IServiceConnection
{
public void OnServiceConnected(ComponentName name, IBinder
service)
{
}
public void OnServiceDisconnected(ComponentName name)
{
}
public IntPtr Handle
{
get { return IntPtr.Zero; }
}
}
private IServiceConnection _connection = new IMDSSConnection();
And here is the call to BindService:
bool status = BindService(new Intent(this,
typeof(BoundService)), _connection, Bind.AutoCreate);
--
View this message in context:
http://mono-for-android.1047100.n5.nabble.com/Bound-Services-tp4872509p4872509.html
Sent from the Mono for Android mailing list archive at Nabble.com.
_______________________________________________
Monodroid mailing list
[email protected]
UNSUBSCRIBE INFORMATION:
http://lists.ximian.com/mailman/listinfo/monodroid