From 5a059bb9d0dad05e6c9cdfea821b15f47b08a8ca Mon Sep 17 00:00:00 2001 From: duqingquan Date: Wed, 26 Jun 2024 15:24:18 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E9=83=A8=E5=88=86=E7=BC=96?= =?UTF-8?q?=E8=AF=91=E5=91=8A=E8=AD=A6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../utssdk/app-android/index.uts | 49 ++++++++++--------- 1 file changed, 25 insertions(+), 24 deletions(-) diff --git a/uni_modules/uts-nativepage/utssdk/app-android/index.uts b/uni_modules/uts-nativepage/utssdk/app-android/index.uts index 1038f61..21fa0d5 100644 --- a/uni_modules/uts-nativepage/utssdk/app-android/index.uts +++ b/uni_modules/uts-nativepage/utssdk/app-android/index.uts @@ -364,32 +364,33 @@ function initShortCut() { console.log("桌面快捷方式 仅支持android 7.1 以上版本") return; } - // 注意 id 不能重复 - let shortcutBuilder = ShortcutInfoCompat.Builder(UTSAndroid.getAppContext()!, "id1"); - shortcutBuilder.setShortLabel("官网") - shortcutBuilder.setLongLabel("访问官网") - shortcutBuilder.setIcon(IconCompat.createWithResource(UTSAndroid.getAppContext()!, R.drawable.icon_short)) - shortcutBuilder.setIntent( - new Intent( - Intent.ACTION_VIEW, - Uri.parse("https://dcloud.io/") - ) - ) - let shortcut = shortcutBuilder.build() - // 注意 id 不能重复 - let shortcutBuilder2 = ShortcutInfoCompat.Builder(UTSAndroid.getAppContext()!, "id2"); - shortcutBuilder2.setShortLabel("示例界面") - shortcutBuilder2.setLongLabel("打开示例界面,最多可以写25个字") - shortcutBuilder2.setIcon(IconCompat.createWithResource(UTSAndroid.getAppContext()!, R.drawable.icon_short)) - shortcutBuilder2.setIntent( - new Intent( - Intent.ACTION_VIEW, - Uri.parse("appuniappx://market/111") - ) - ) - let shortcut2 = shortcutBuilder2.build() + // #ifdef UNI-APP-X + // 注意 id 不能重复 + let shortcutBuilder = ShortcutInfoCompat.Builder(UTSAndroid.getAppContext()!, "id1"); + shortcutBuilder.setShortLabel("官网") + shortcutBuilder.setLongLabel("访问官网") + shortcutBuilder.setIcon(IconCompat.createWithResource(UTSAndroid.getAppContext()!, R.drawable.icon_short)) + shortcutBuilder.setIntent( + new Intent( + Intent.ACTION_VIEW, + Uri.parse("https://dcloud.io/") + ) + ) + let shortcut = shortcutBuilder.build() + // 注意 id 不能重复 + let shortcutBuilder2 = ShortcutInfoCompat.Builder(UTSAndroid.getAppContext()!, "id2"); + shortcutBuilder2.setShortLabel("示例界面") + shortcutBuilder2.setLongLabel("打开示例界面,最多可以写25个字") + shortcutBuilder2.setIcon(IconCompat.createWithResource(UTSAndroid.getAppContext()!, R.drawable.icon_short)) + shortcutBuilder2.setIntent( + new Intent( + Intent.ACTION_VIEW, + Uri.parse("appuniappx://market/111") + ) + ) + let shortcut2 = shortcutBuilder2.build() ShortcutManagerCompat.setDynamicShortcuts(UTSAndroid.getAppContext()!, [shortcut,shortcut2].toKotlinList()) // #endif // #ifndef UNI-APP-X -- GitLab