Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Creating a Main Activity which DOES NOT appear in the launcher list

I'm looking for a way to have my app launch an activity when opened directly from the Android market, yet not maintain an activity in the launcher menu. I thought that by using the following settings, I would be able to achieve this:

    <activity android:name="com.package.test.MyActivity" android:label="@string/app_name">
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />
        </intent-filter>
    </activity>

However, it appears that with these settings the Activity seemingly doesn't even exist in the app - it cannot be opened from the market and doesn't appear in the launcher menu. However, by simply adding:

<category android:name="android.intent.category.LAUNCHER" />

the app does both. The problem is I do want the activity to run from the Market, but I don't want it in the launcher menu.

Can anyone enlighten me as to how this can be achieved?

like image 673
AaronDS Avatar asked Mar 05 '12 22:03

AaronDS


People also ask

How to add an activity in manifest file?

To declare your activity, open your manifest file and add an <activity> element as a child of the <application> element. For example: <manifest ... > The only required attribute for this element is android:name, which specifies the class name of the activity.

What is main activity in Android application?

The "main" activity is the activity that loads first and the rest of your application. Every application can have multiple activities, therefore you can list other activities to load and use later on but you can only have one "main" activity.

What is an activity in Android*?

Activity is a single screen in an application, Activity performs the actions on the screen(UI)


1 Answers

Instead of LAUNCHER, use android.intent.category.INFO. Know that this is not used often, but an example is an add-on package like the Beautiful Widgets animations, where an informational screen beyond the Market listing is useful after the app is installed, but no harm will be done if the user never discovers this activity.

(See also this question.)

like image 144
Josh Lee Avatar answered Sep 22 '22 10:09

Josh Lee