简体   繁体   中英

Android Manifest, how to disable launcher icon for lower api

i have an accessibility application ive written, but on android 4.0 and higher, the api allows for a settings activity to be set. This defeats the purpose of having a launcher entry. Is there a way to single out 4.0 and higher systems in the manifest to not have the launcher icon?

EDIT: solution

I subclassed the original settings to a JB/ICS one. this is pretty uncessesary at this point, but if something JB/ICS specific is added to the app, it would probably be good in the long run to keep them seperate.

thanks alanv, your snippet did still help

You can selectively disable an activity based on the platform version. Add an activity alias for your Settings activity and set the enabled attribute to a platform-specific value. This will ensure that it only shows up in the Launcher when you need it to.

AndroidManifest.xml:

<activity
    android:name=".MySettingsActivity"
    . . . >
</activity>

<activity-alias
    android:name=".MyActivityAlias"
    android:label="@string/settings"
    android:targetActivity=".MySettingsActivity"
    android:enabled="@bool/show_settings">
        <intent-filter>
        . . .
        </intent-filter>
</activity-alias>

values-v14/bool.xml:

<bool name="show_settings">false</bool>

values/bool.xml:

<bool name="show_settings">true</bool>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM