[mono-android] Binding services
Jon Dick
jondick at gmail.com
Tue Mar 22 21:26:52 EDT 2011
I'd add that I've mostly opted to find .net ways around using service
bindings.. It won't be the best in all cases, but a simple static event
living in the service class that passes a reference to itself to the event
handler can go a long way :)
Then you make your Activity register and unregister for the event on its
resume and pause overrides... Simple, and I don't think the performance or
memory implications are terrible.
---
Jon (aka Redth)
On Tue, Mar 22, 2011 at 9:22 PM, Jonathan Pryor <jpryor at novell.com> wrote:
> On Mar 22, 2011, at 8:15 PM, Brian Long wrote:
> > Am I right in thinking that binding to a service is not on the table with
> MonoDroid?
>
> Binding to a service and using AIDL are related but not identical.
>
> You _can_ start a Service using Context.StartService()[0], bind to a
> service using Context.BindService()[1] , unbind using
> Context.UnbindService()[2], and use the service. We even have a sample [3,
> 4]. :-)
>
> Where AIDL comes in is when you want to use Inter-Process Communication to
> a Service hosted in another process, as AIDL is used to describe the
> messages that can be sent to the Service. This is not currently "natively"
> supported by Mono for Android, but it should be possible to use Mono for
> Android's Java interop features [5, 6] to run the `aidl` program as a
> pre-build step to generate .java sources, then implement and include those
> .java sources into your build so that your app and other apps may use them.
>
> - Jon
>
> [0]
> http://docs.mono-android.net/index.aspx?link=M%3aAndroid.Content.Context.StartService(Android.Content.Intent)
>
> [1]
> http://docs.mono-android.net/index.aspx?link=M%3aAndroid.Content.Context.BindService(Android.Content.Intent%2cAndroid.Content.IServiceConnection%2cAndroid.Content.Bind)
>
> [2]
> http://docs.mono-android.net/index.aspx?link=M%3aAndroid.Content.Context.UnbindService(Android.Content.IServiceConnection)
>
> [3]
> https://github.com/mono/monodroid-samples/blob/master/ApiDemo/App/LocalService.cs
>
> [4]
> https://github.com/mono/monodroid-samples/blob/master/ApiDemo/App/LocalServiceActivities.cs
>
> [5]
> http://mono-android.net/Documentation/API_Design#Jave_Native_Interface_Support
>
> [6] https://github.com/mono/monodroid-samples/tree/master/GoogleMaps
>
> _______________________________________________
> Monodroid mailing list
> Monodroid at lists.ximian.com
>
> UNSUBSCRIBE INFORMATION:
> http://lists.ximian.com/mailman/listinfo/monodroid
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.ximian.com/mailman/private/monodroid/attachments/20110322/ea732b11/attachment.html
More information about the Monodroid
mailing list