Found these after posting:
http://code.google.com/p/android/issues/detail?id=2665 http://code.google.com/p/android/issues/detail?id=2483
MyApp - first Activity that calls startService();
AwesomeService - background Service that starts a "connection" thread
ConnectedActivity - Activity with code to handle connection and service binding
MyAppActivity - Tabbed Activity
TabAActivity - Tab Activity
I have an Activity base class called ConnectedActivity. In this class I handle binding to a background Service that is connected to a remote system. The ConnectedActivity also has observer methods that capture changes in the connection and other notifications from the Service.
For my other Activities, that need to be "connected", I simply extend the ConnectedActivity.
I have developed a Tabbed Activity, for which the Tabs are also Activities. For the Tabbed Activity and each of the Tabs, I need to extend the ConnectedActivity.
The problem I am having is that when I load the Tabbed Activity (and Tab Activities), it is the only Activity that binds to the Service. The Tab Activities don't bind to the Service.
Below, serviceBound() is a callback that I have implemented in the ConnectedActivity class so that classes that are extending the ConntectedActivity can take action once the service is bound. You can see from my Log file that only the MyAppActivity is actually binding.
Is it possible for multiple Activities to bind to a Service?
EDIT: found this here
Multiple clients can connect to the service at once. However, the system calls your >service's onBind() method to retrieve the IBinder only when the first client binds. The system then delivers the same IBinder to any additional clients that bind, without calling onBind() again
So now my real question becomes.. does this mean the callbacks (onServiceConnected() & onServiceDisconnected) do not get called in the "second" activity that's binding?
END EDIT:
12-31 02:40:00.625: I/MyApp(31345): onCreate(Bundle savedInstanceState)
12-31 02:40:00.705: I/AwesomeService(31345): onCreate()
12-31 02:40:00.705: I/AwesomeService(31345): onStartCommand(Intent intent, int flags, int startId)
12-31 02:40:00.725: I/ConnectedActivity(31345): onCreate(Bundle savedInstanceState)
12-31 02:40:00.725: I/MyAppActivity(31345): onCreate(Bundle savedInstanceState)
12-31 02:40:00.836: I/ConnectedActivity(31345): onCreate(Bundle savedInstanceState)
12-31 02:40:00.836: I/TabAActivity(31345): onCreate(Bundle savedInstanceState)
12-31 02:40:00.896: I/ConnectedActivity(31345): onStart()
12-31 02:40:00.896: I/TabAActivity(31345): onStart()
12-31 02:40:00.956: I/ConnectedActivity(31345): onStart()
12-31 02:40:00.966: I/MyAppActivity(31345): onStart()
12-31 02:40:00.966: I/ConnectedActivity(31345): onResume()
12-31 02:40:00.966: I/MyAppActivity(31345): onResume()
12-31 02:40:00.966: I/ConnectedActivity(31345): onResume()
12-31 02:40:00.966: I/TabAActivity(31345): onResume()
12-31 02:40:00.976: I/AwesomeService(31345): onBind(Intent intent)
12-31 02:40:01.056: I/ConnectedActivity(31345): onServiceConnected(ComponentName className, IBinder service)
12-31 02:40:01.056: I/AwesomeService(31345): LocalBinder:getService()
12-31 02:40:01.056: I/MyAppActivity(31345): serviceBound()
I was hoping to also see:
AwesomeService(31345): onBind(Intent intent)
ConnectedActivity(31345): onServiceConnected(ComponentName className, IBinder service)
AwesomeService(31345): LocalBinder:getService()
TabAActivity(31345): serviceBound()