I have an android application that I’m developing, and the application really just a few tasks and then exits when its done. Right now I have an activity that displays a button, and when I press it, it runs the task.
Basically I just want an application where launching it just runs that task and closes the application. Is the way to go about this just to create an activity that doesn’t create a GUI? Right now my manfiest xml file also lists
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
Would those need to be changed?
You could start a service from your activity that does the actual work, and then call
finish(). That would close the activity, and won’t display a GUI. Make sure the service executes your task in a new thread, because otherwise it will still block the UI thread. Also keep in mind that a service could be restarted, so be ready to handle this.