diff --git a/PackageStructureKit/entry/src/main/a_app_module.json5 b/PackageStructureKit/entry/src/main/a_app_module.json5 new file mode 100644 index 0000000000000000000000000000000000000000..73191e189e758a0d3c87a4667be409b78472a96a --- /dev/null +++ b/PackageStructureKit/entry/src/main/a_app_module.json5 @@ -0,0 +1,65 @@ +/* +* FAQ:如何判断应用程序是否安装 + */ + +{ + "module": { + "name": "entry", + "type": "entry", + "description": "$string:module_desc", + "mainElement": "EntryAbility", + "deviceTypes": [ + "phone", + "tablet", + "2in1" + ], + "deliveryWithInstall": true, + "installationFree": false, + "pages": "$profile:main_pages", + "abilities": [ + { + "name": "EntryAbility", + "srcEntry": "./ets/entryability/EntryAbility.ets", + "description": "$string:EntryAbility_desc", + "icon": "$media:layered_image", + "label": "$string:EntryAbility_label", + "startWindowIcon": "$media:startIcon", + "startWindowBackground": "$color:start_window_background", + "exported": true, + "skills": [ + { + "entities": [ + "entity.system.home" + ], + "actions": [ + "action.system.home" + ], + // [Start a_app_module] + "uris": [ + { + "scheme":"schB", + "host":"com.example.test", + "path":"open", + } + ], + // [End a_app_module] + } + ] + } + ], + "extensionAbilities": [ + { + "name": "EntryBackupAbility", + "srcEntry": "./ets/entrybackupability/EntryBackupAbility.ets", + "type": "backup", + "exported": false, + "metadata": [ + { + "name": "ohos.extension.backup", + "resource": "$profile:backup_config" + } + ], + } + ] + } +} \ No newline at end of file diff --git a/PackageStructureKit/entry/src/main/b_app_module.json5 b/PackageStructureKit/entry/src/main/b_app_module.json5 new file mode 100644 index 0000000000000000000000000000000000000000..56a59c3cd9e1e81ec50fe4d7e644cad313773e21 --- /dev/null +++ b/PackageStructureKit/entry/src/main/b_app_module.json5 @@ -0,0 +1,61 @@ +/* +* FAQ:如何判断应用程序是否安装 + */ + +{ + "module": { + "name": "entry", + "type": "entry", + "description": "$string:module_desc", + "mainElement": "EntryAbility", + // [Start b_app_module] + "querySchemes": [ + "schB" + ], + // [End b_app_module] + "deviceTypes": [ + "phone", + "tablet", + "2in1" + ], + "deliveryWithInstall": true, + "installationFree": false, + "pages": "$profile:main_pages", + "abilities": [ + { + "name": "EntryAbility", + "srcEntry": "./ets/entryability/EntryAbility.ets", + "description": "$string:EntryAbility_desc", + "icon": "$media:layered_image", + "label": "$string:EntryAbility_label", + "startWindowIcon": "$media:startIcon", + "startWindowBackground": "$color:start_window_background", + "exported": true, + "skills": [ + { + "entities": [ + "entity.system.home" + ], + "actions": [ + "action.system.home" + ] + } + ] + } + ], + "extensionAbilities": [ + { + "name": "EntryBackupAbility", + "srcEntry": "./ets/entrybackupability/EntryBackupAbility.ets", + "type": "backup", + "exported": false, + "metadata": [ + { + "name": "ohos.extension.backup", + "resource": "$profile:backup_config" + } + ], + } + ] + } +} \ No newline at end of file diff --git a/PackageStructureKit/entry/src/main/ets/pages/IndexA.ets b/PackageStructureKit/entry/src/main/ets/pages/IndexA.ets new file mode 100644 index 0000000000000000000000000000000000000000..f33d7b3502da9cf3d44a5c3555803d97087b0081 --- /dev/null +++ b/PackageStructureKit/entry/src/main/ets/pages/IndexA.ets @@ -0,0 +1,61 @@ +/* +* Copyright (c) 2024 Huawei Device Co., Ltd. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/* +* FAQ:如何判断应用程序是否安装 + */ + +// [Start is_app_b_exist] +import { hilog } from '@kit.PerformanceAnalysisKit'; +import { bundleManager } from '@kit.AbilityKit'; +import { BusinessError } from '@kit.BasicServicesKit'; + +@Entry +@Component +struct Index { + // Application A determines whether Application B is installed on the device + isAppBExist() { + let exist = false; + try { + let link = 'schB://com.example.test/open'; + let data: boolean = bundleManager.canOpenLink(link); + hilog.info(0x0000, 'testTag', 'canOpenLink successfully: %{public}s', JSON.stringify(data)); + exist = data; + } catch (err) { + let message = (err as BusinessError).message; + hilog.error(0x0000, 'testTag', 'canOpenLink failed: %{public}s', message); + exist = false; + } + console.info('Has application B been installed:' + exist); + } + + @State text: string = 'isAppBExist' + + build() { + Row() { + Column() { + Text(this.text) + .fontSize(30) + .fontWeight(FontWeight.Bold) + .onClick(() => { + this.isAppBExist(); + }); + } + .width('100%') + } + .height('100%') + } +} +// [End is_app_b_exist] \ No newline at end of file diff --git a/PackageStructureKit/entry/src/main/resources/base/profile/main_pages.json b/PackageStructureKit/entry/src/main/resources/base/profile/main_pages.json index 1898d94f58d6128ab712be2c68acc7c98e9ab9ce..cce56d0acbb9ec973a457874c7fd4bc6698aa9d6 100644 --- a/PackageStructureKit/entry/src/main/resources/base/profile/main_pages.json +++ b/PackageStructureKit/entry/src/main/resources/base/profile/main_pages.json @@ -1,5 +1,6 @@ { "src": [ - "pages/Index" + "pages/Index", + "pages/IndexA" ] -} +} \ No newline at end of file