Created
January 18, 2012 19:39
-
-
Save caseycrites/1635098 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 11:31 AM S3nsat10n | |
| Do you have to create an IDL in order to interact with a service running in another process inside your own app? Or can you bind to it like you would a service running in the main process? | |
| 11:31 AM evancharlton | |
| you can just bind to it | |
| 11:31 AM lov | |
| S3nsat10n: it depends. | |
| 11:31 AM pfn | |
| S3nsat10n, another process = need idl | |
| 11:31 AM evancharlton | |
| IDL is pretty much just for IPC as far as I know | |
| 11:31 AM lov | |
| S3nsat10n: you don't need to use aidl; you may want to use messages | |
| 11:31 AM pfn | |
| S3nsat10n, or if you're willing to use a Messenger/Handler, you can communicate that way | |
| 11:31 AM lov | |
| there's a good docs about this | |
| 11:31 AM pfn | |
| use IDL for tight-coupling, Messenger/Handler for loose-coupling | |
| 11:32 AM S3nsat10n | |
| I've been reading up a bit, but got confused whether it was only talking about services in other apps...hence my question | |
| 11:32 AM lov | |
| http://developer.android.com/guide/topics/fundamentals/bound-services.html | |
| 11:32 AM lov | |
| basically, if the service is in another process it (by definition) doesn't live in your own process space | |
| 11:32 AM lov | |
| so you can't just take the service object and call methods directly | |
| 11:32 AM | |
| you either use aidl to send your communications or you use a messenger | |
| 11:32 AM virunga has left IRC (Read error: Connection reset by peer) | |
| 11:32 AM S3nsat10n | |
| ok, so either an IDL or a messenger | |
| 11:32 AM lov | |
| messenger is sufficient if you don't need to worry about synchronization | |
| 11:32 AM lov | |
| s/synchronization/multithreading | |
| 11:33 AM S3nsat10n | |
| will both of those work if you decide to run the service in the foreground? | |
| 11:33 AM | |
| basically, I have a service in a library that the dev can decide to run in the background or foreground | |
| 11:33 AM lov | |
| that's irrelevant to this | |
| 11:33 AM S3nsat10n | |
| and I want to have an interface that works for either | |
| 11:33 AM lov | |
| I don't really know what you mean by "background or foreground" | |
| 11:33 AM | |
| see http://developer.android.com/guide/topics/fundamentals/bound-services.html#Messenger | |
| 11:33 AM S3nsat10n | |
| sorry | |
| 11:33 AM | |
| in the main process or another process | |
| 11:33 AM lov | |
| ah | |
| 11:33 AM pfn | |
| aidl | |
| 11:33 AM lov | |
| your service should really only live in one process; pick one | |
| 11:34 AM lov | |
| if you're including your service with multiple apps, very strongly consider whether you want to actually export that service. | |
| 11:34 AM | |
| if you do export it, you run the risk of version related problems | |
| 11:34 AM | |
| if you don't export it, you could have multiple apps running their own service simultaniously | |
| 11:34 AM | |
| I guess it depends on what the service does really | |
| 11:34 AM luxurymode | |
| lov, i always would use started service with a bunch of static methods in the service class to control the media stuff and then send broadcasts from the service to notify interested activities about media playback events. does this make sense? also i still dont think im clear on this: a Service, by default, runs in the same process as the rest of the app, correct? | |
| 11:35 AM S3nsat10n | |
| lov: it's a location service | |
| 11:35 AM S3nsat10n | |
| pfn: aidl will work whether the service is in the main or separate process? | |
| 11:35 AM lov | |
| luxurymode: unless you explicitly set a different process, yes, a service lives in the same process as the rest of its application | |
| 11:35 AM pfn | |
| S3nsat10n, that's the point of using aidl | |
| 11:35 AM S3nsat10n | |
| pfn: good to know |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment