I would like to ask for some example, where two different activities (a button in the first activity opens a second activity), are communicating with one service (AIDL, etc.).
I’ve tried many different tutorials, but they are only about how to make one activity → one service.
This is probably old, but I’ll try to answer it anyway…
In Android, seeing as only one
Activitycan bind to aServiceat a time, and only oneActivitycan be shown at a time, there isn’t any real reason to want to bind two Activities at a time.But, if you’d like, the best solution is to bind the
Servicein theonResume()method, and unbind it in theonPause()method. This allows you to give two unrelated Activities access to the service, while only having one bound at a time.