Vote count:
0
I am confused.
I have an application which I believe needs to implement a service. This service is specific to the application; when the application actually dies or is manually terminated, the service can go away. The application will be in constant communication with the service, ideally by the activity calling methods of the service itself.
This implies to me that the service should be a Bound Service.
However, when I rotate the phone after having bound the service, the main activity calls onStop(), and I get a leaked serviceConnection squawk. I thought the whole point of services was not to nuke themselves when application rotated, or lost focus, etc.
I suppose I could simply disable the rotation feature in the application, but that's sub-optimal because having a different layout for different orientations is highly desired. It also seems to be just bad form to do this, because if some other application takes the focus I'll still run into the same problem.
I think (but am not sure) that if this were a started service, the call to onStop() would be circumvented, but then I could not call methods on it.
How is this done in practice: How do I get a service implemented so that I can call methods on it directly, but not have the OS complain when I rotate the phone? Is there way to start the method in the activity and then bind to it? Would that even work?
Android: BoundService and leaked ServiceConnection
Aucun commentaire:
Enregistrer un commentaire