Creating an Android Activity with no UI

How do you create an Activity based applications with no UI?

The answer is that you need to set the activity theme in the manifest, for RosieUtility I use:

android:theme="@android:style/Theme.Translucent.NoTitleBar"

Like this in AndroidManifest.xml:

<activity android:name=".MainActivity"
android:theme="@android:style/Theme.Translucent.NoTitleBar"
android:label="@string/app_name">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>

If you just want to kick off something quick, you’ll also want to call “finish();” after firing the intent in onCreate of Activity

The latest set of activity themes are defined in /res/values/themes.xml in the Android source here.

Note I’m not using the theme ‘NoDisplay’ as I do actually show notifications on the screen as the Activity is going about its business.

Source

Advertisements

One thought on “Creating an Android Activity with no UI

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s