Android Activity without UI

Is it possible to create a Android activity without UI?

Yes it is. Android provides a theme for this requirement. Add the following line to your AndroidManifest.xml and call finish() at the end of the Activity’s onCreate() method.



public static final class – Added in API level 3
int Theme_NoDisplay
Default theme for activities that don’t actually display a UI; that is, they finish themselves before being resumed.

Constant Value: 16973909 (0x01030055)

Android Background Service Template

This is a simple Android background Service Template. You can use it to run updates in the background without blocking the UI. To start and stop the service use the following lines in your activity:

This is all you need to execute a service on android devices. Don’t forget to add the service to your AndroidManifest.xml file.