On Sun, Jul 11, 2010 at 12:04 PM, Sean Chitwood <[email protected]> wrote:
> I'm binding to the service and then starting it so that I can get
> the notification of the propertyUpdate.
That makes no sense to me, sorry. Most of the time, you only need one
or the other, not both. Why do you think you need both in this case?
> As far as dssShow not being assigned to:
>
> in bindService(i, mConnection, Context.BIND_AUTO_CREATE);
>
> mConnection is an instance of a ServiceConnection object that has a
> onServiceConnected handler which is supposed to fire when the
> connection is made (in my understanding). That code is copy pasted
> from the SDK with minor tweeks:
>
>
> protected ServiceConnection mConnection = new ServiceConnection() {
> public void onServiceConnected(ComponentName className,
> IBinder service) {
> // This is called when the connection with the service has been
> // established, giving us the service object we can use to
> // interact with the service. Because we have bound to a explicit
> // service that we know is running in our own process, we can
> // cast its IBinder to a concrete class and directly access it.
> dssShow = (DownloadShowsService)
> ((DownloadShowsService.LocalBinder)service).getService();
>
>
> }
>
> public void onServiceDisconnected(ComponentName className) {
> // This is called when the connection with the service has been
> // unexpectedly disconnected -- that is, its process crashed.
> // Because it is running in our same process, we should never
> // see this happen.
> dssShow = null;
>
> }
> };
As I wrote:
>> Also, bear in mind that bindService() and startService() are both
>> asynchronous.
The code you originally posted assumes that bindService() is
synchronous. It is not. Do not attempt to use dssShow two statements
after bindService(). Do not reference dssShow until
onServiceConnected() is called.
--
Mark Murphy (a Commons Guy)
http://commonsware.com | http://github.com/commonsguy
http://commonsware.com/blog | http://twitter.com/commonsguy
Android Training...At Your Office: http://commonsware.com/training
--
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en