java - Android library module with extendable service -
i need develop android library has service component. service requirements are:
- works started service (always started)
- started , restarted alarm service when required (another service within library)
- started system boot (boot_completed)
- provide way subscribe service events (which should executed in context of service, mean in background well)
the purpose of service provide client (android application) use ability subscribe events should executed in background. dure limitation extended client should receive notification in background (even when client not started) can see extension service (derived service reconfigured @ manifest @ client app).
what proper approach achieve goal? how should base service communicate client extension?
so first client have add service androidmanifest.xml
. client call methods library start service or alarm service, depending on needs.
communication depends on data want send service client's app. if it's notification best way use broadcastreceiver
. if register receiver in androidmanifest.xml
receive intents when app not started.
if want send lot of objects or call method on service can use serviceconnection
, binder.
for instance, need client receive list<model>
service if client not started. declare broadcastreceiver
in androidmanifest.xml
receive intent depending on intent filter. bind service via serviceconnection
, pass callback object. after start background thread inside service load data. once it's done, call callback method , client app receive data.
not sure if answered question because it's bit abstract.
Comments
Post a Comment