Possible Duplicate:
Start android application without activity
I want to do a download tool for other apps. It would always run in background. All code in service. So no need for a UI. How do I do this?
Possible Duplicate:
Start android application without activity
I want to do a download tool for other apps. It would always run in background. All code in service. So no need for a UI. How do I do this?
You can still have an Activity just don't declare an intent-filter in your manifest, that way the user can never start your app from the menu and therefore never see the Activity unless you choose to show it. Going further you could make the Activity theme Transparent as well so that if it is brought to the front it doesn't show anything.
The kind of examples to look at would be a Live Wallpaper app.
http://developer.android.com/resources/samples/CubeLiveWallpaper/index.html
^ Ignore the actually wallpaper bits but notice that the app doesn't have an Activity
You can create a BroadcastReceiver
that will start your Service
and remove the Activity
from the Manifest file.
<activity android:name=".StarterActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
The action MAIN and category LAUNCHER start the application, so remove <intent-filter>
of StarterActivity from the <application>
. Then your application will not visible into the applications list.