Service based Android application on Google Play S

2019-03-02 09:33发布

问题:

I'm developing an application which will consists only of a few services and no activities (i.e. no UI)
Basically I want to have 2 to 3 services to be running in the background right from when user installs the application on his/her device.

I have a few questions over this:

  1. How will my services start after application installation? My BroadcastReceiver should be listening to which event?
  2. How can I package my application to deploy it application on Googly Play Store?

回答1:

You can't do that on newer Androids. Android specifically requires user interaction before starting up services - the user will need to physically start your application. And if your application doesn't show anything, the user is going to be very confused.

So create one Activity explaining the user what has just happened, and register your receivers there.