Two shortcut with Two Icons for the same App

回眸只為那壹抹淺笑 提交于 2019-12-23 23:43:28

问题


So , i want to have an additional Shortcut with another Icon for the same App , this additional Shortcut , Visible in App Drawer , should launch a Simple Activity/Service ,

it is Possible , If yes How ? If Possible , Programmaticly ,

Does its matter with < application > Tag ? ,

Thanks


回答1:


Of course you can have two or more launcher activities in your application. Just set an intent filter with launch attributes.

<activity
    android:name=".SecondActivity"
    android:icon="@drawable/ic_second_launcher">
    <intent-filter>
        <action android:name="android.intent.action.MAIN"/>
        <category android:name="android.intent.category.LAUNCHER"/>
    </intent-filter>
</activity>

If you want to start a service from the AppDrawer, just call an empty Activty which starts the Service in onCreate



来源:https://stackoverflow.com/questions/17907167/two-shortcut-with-two-icons-for-the-same-app

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