java - Android two-way service communication -
i have activity , local bound service. i've got bound service , running fine, can handle communication client server, through functions on server/binder interface.
however need 2 way communication, service @ point need notify activity (and user) happened, , needs wait user action before proceeding. in other words, need servers calls clients synchronous or blocking. i.e. when service calls function pass few parameters on client, trigger alertdialog user use, , options determine return status code sent service. until point, want service halt , wait until has recieved response, determine there (service continues run, service shuts down etc.)
so there way in android this? need reference activity, , needs expose these blocking methods can call them service , wait response. i've got interface client activity, i'm struggling on how on service. don't want use serialization , add reference intent extra, both client , service have many members not want serializable.
thanks.
- you can use broadcasts send info service activity.
- every call of
startservice()
inside activity class call onstartcommand() method of service class, can send message inside intent. - use service binding make own info transfer.
Comments
Post a Comment