方法一:在配置文件中静态声明,shortcut的图标,文字,提示文字,跳转意图,跳转参数等。
步骤一:在res文件夹中新建xml文件夹,在其中新建shortcuts.xml,按照如下方式写
<?xml version="1.0" encoding="utf-8"?>
<shortcuts xmlns:android="http://schemas.android.com/apk/res/android">
<shortcut
android:enabled="true"
android:icon="@drawable/ic_short_cut_market"
android:shortcutDisabledMessage="@string/look_round_market_disable"
android:shortcutId="market"
android:shortcutLongLabel="@string/look_round_market"
android:shortcutShortLabel="@string/look_round_market">
<!--但是这样做比较死板,不能起到管理的作用-->
<intent
android:action="android.intent.action.VIEW"
<!--Activity路径-->
android:targetClass="com.xxx.activity.act.home.MainActivity"
<!--给固定intent,添加参数-->
android:data="zze://xxx.com/main/main?tab=1"
<!--你的包名-->
android:targetPackage="com.xxx.activity"/>
</shortcut>
</shortcuts>
步骤二:在你的launch Activity 中添加元素
<application
...
>
<activity
android:name=".SplashAct"
android:screenOrientation="portrait"
android:theme="@style/Theme.AppCompat.Light.NoActionBar">
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.LAUNCHER"/>
</intent-filter>
<!--添加shortcuts元素-->
<meta-data
android:name="android.app.shortcuts"
android:resource="@xml/shortcuts"/>
</activity>
...
</application>
效果图: