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

柔情痞子 提交于 2021-02-07 07:36:38

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!