Android application as a service without activity -
i making set of apps , have pretty much same background service of them.
i'm trying create app has service
. don't repeat in of them, thing don't need activity
. because there no ui needed it, , user can't close except if stop service
.
i tried remove activity
, app doesn't run or start. my question is: can create app google play services
other apps can utilize service
.
if yes snippet or sample welcome.
sure! no reason cannot have application service. ...and no need aidl unless want to.
the problem is, how create application run. when create application activity, add together intent filter, in manifest, makes activity startable launcher. if there's no activity, you'll have find way start it.
it easy do, though. fire intent 1 of other programs, this:
startservice(new intent("my.service.intent"));
... service registered manifest, this:
<service android:name=".someservice" > <intent-filter> <action android:name="my.service.intent"/> </intent-filter>
you utilize intent pass parcelable parameters service, , service can reply broadcasting intents back.
of course of study startservice , broadcastintent bit clunky if need complex api between applications , service. if need richer, will want aidl , bound service.
edited add together intent filter
android android-service google-play-services background-service
No comments:
Post a Comment