问题
Can I make an apk that only has a service?
I'm trying to make a long running service that sits in the back and updates a database. No UI.
I always thought that a Service had to be bootstrapped to an Activity in order to make an APK but is that true?
回答1:
You can, but you might have problems. Google prohibits an app from starting an Activity with an "action" - something from the user.
See this post: How to start android service on installation
It may be possible to capture a user action not related to "your" activity, as suggested in that post and like this:
Can I start a service without activity or receiver?
However, I'm pretty sure that the last time I checked, the "start service" portion of Android required a user-visible activity to be displayed. Otherwise, malicious activities may occur without the user recognizing that an app was even installed or acknowledged.
来源:https://stackoverflow.com/questions/27256324/is-it-possible-to-make-an-apk-with-no-activity