Android service - invoking methods and passing objects, without binding -


i have app need establish , maintain bluetooth connection phone. however, connection needs remain alive if screen turns off.

so way i've done 1) make service connection can exist in background , 2) make explicit call start/stop service instead of binding activity (i believe if screen goes off, activity goes away, service stop)

this has made things more complicated because service has methods need able manually invoke. example, want start bluetooth discovery when user clicks button. on button click, need tell service call startdiscovery method. there many situations (e.g. open socket, pair device etc) need manually call service methods

a lot of i've read on topic solves binding service, cannot explained earlier

without binding, others suggest use sort of event bus, on button click send message service. when receives message, checks type of message , invokes appropriate method.

ok, works, if method requires me pass it? example, lets have list or need send on bluetooth. have method in service takes list object, serializes , sends on bt other phone. doesn't seem possible basic messaging/event bus system

in sum, how pass object through method in service not bound activity, instead has been manually started startservice?

i have seen question here, method seems allow me send objects when start service. in case, service started , sits in background handling bluetooth traffic. need able invoke methods , pass objects while service running

i have done similar in service. need manually hide notification service created. made method public , static can called anywhere this:

public static void hidenotification(){     notificationmanager.cancel(0); } 

then call in activity this: myservice.hidenotification()

edit

if not want static method, can create empty constructor service , when need call method, create new instance of service , call that. example:

in service:

public class myservice extends service{     public myservice(){}      public void hidenotification(){         notificationmanager.cancel(0);     } } 

when need call method:

myservice service = new myservice(); service.hidenotification();