1

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?

Josh Elias
  • 3,250
  • 7
  • 42
  • 73
  • possible duplicate of [Launch Android application without main Activity and start Service on launching application](http://stackoverflow.com/questions/10909683/launch-android-application-without-main-activity-and-start-service-on-launching) – Tim Dec 02 '14 at 18:24
  • I don't think this is a duplicate since it is related to a complete "app" as opposed to the "concept" of starting a service where the app may not be active but still have one or more activities... – Jim Dec 02 '14 at 18:31
  • Why don't you just make an apk without a service and find out. You could've been done you've had 10 hours. – danny117 Dec 03 '14 at 04:38
  • What's the big deal a activity without UI minus 1 again If I could – danny117 Dec 03 '14 at 04:41
  • There are differences between an Activity and a Service that extend beyond the UI. That's probably why they only let you minus once :) – Josh Elias Dec 10 '14 at 19:01

1 Answers1

2

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.

Community
  • 1
  • 1
Jim
  • 10,172
  • 1
  • 27
  • 36