安卓7.0添加Shortcut静态快捷方式

manifest.xml 中 入口Activity中添加 <meta-data> 标签

<meta-data android:name="android.app.shortcuts"
                android:resource="@xml/shot_shortcut" />

其中name的值是固定的,resource为shortcut具体的配置文件信息。

shot_shortcut.xml 文件具体配置如下

<shortcuts xmlns:android="http://schemas.android.com/apk/res/android">

    <shortcut
        android:shortcutId="shortcut_identify"    //要唯一
        android:enabled="true"
        android:icon="@drawable/shortcut_icon"    //快捷方式图标
        android:shortcutShortLabel="@string/shortcut_short"   //快捷方式的短名称
        android:shortcutLongLabel="@string/shortcut_long"         //快捷方式的长名称,优先使用长名称
        android:shortcutDisabledMessage="@string/shortcut_disabled">    //快捷方式被禁用信息
        <intent
            android:action="android.intent.action.VIEW"    //
            android:targetPackage="com.demo.shortcutsTest"    //包名
            android:targetClass="com.demo.shortcutsTest.MainActivity" />    //具体要跳到的类
			
		<categories android:name="android.shortcut.conversation" />	 //目前只有这个categories分类
    </shortcut>
	
	<!--每个应用最多可以注册5个Shortcuts-->
	
</shortcuts>

按照上面的配置基本就完成了静态快捷方式的创建了



                
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值