Android原生开发笔记 给应用页面注册快捷方式

java yekong 492℃

Android原生开发笔记 给应用页面注册快捷方式

添加shortcut

main>res>xml>shortcuts.xml
添加shortcut

<?xml version="1.0" encoding="utf-8"?>
<shortcuts xmlns:android="http://schemas.android.com/apk/res/android">
    <shortcut
        android:enabled="true"
        android:icon="@mipmap/ic_launcher"
        android:shortcutId="first"
        android:shortcutLongLabel="@string/name"
        android:shortcutShortLabel="@string/shortLabel">
        <intent
            android:action="android.intent.action.VIEW"
            android:targetClass="com.example.chapter03.TextViewActivity"
            android:targetPackage="com.example.chapter03"></intent>
        <categories android:name="android.shortcut.conversation"></categories>
    </shortcut>
</shortcuts>

AndroidManifest.xml 配置

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

strings配置

1672649424821EmZ3Hw

<resources>
    <string name="app_name">chapter03</string>
    <string name="name">启动页面</string>
    <string name="shortLabel">first</string>
</resources>
喜欢 (0)