问题
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?
回答1:
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.)
来源:https://stackoverflow.com/questions/9574886/creating-a-main-activity-which-does-not-appear-in-the-launcher-list