+
+
+## Project Directory
+
+```
+├──entry/src/main/ets // Code area
+│ ├──common
+│ │ ├──Logger.ets // Logger
+│ | └──Constants.ets // Constants
+│ ├──entryability
+│ | └──EntryAbility.ets
+│ ├──entrybackupability
+│ | └──EntryBackupAbility.ets
+│ └──pages
+│ ├──Index.ets // Entry page
+│ └──OriginPage.ets // Origin page
+└──entry/src/main/resources // App resource directory
+```
+
+## How to Implement
+
+To start a native page from a web page, you need to intercept page loading using the interceptor **onLoadIntercept** of the **Web** component and use the routing capability of the **Navigation** component.
+
+To start another web page from a web page, you only need to configure the **a** tag with the **href** property on the frontend.
+
+To start a third-party application from the web page, you need to intercept the page loading using **onLoadIntercept** of the **Web** component and then execute the custom startup logic. Before starting the third-party application, you need to set the **exported** property of the **module.json5** file of the third-party application to **true**. In addition, you need to configure **entities** and **actions** in the **skills** property. Use the implicit startup mode in the application and configure the parameters of the **Want** type. The **action** and **entities** parameters specify the actions and entities of the application to be started respectively. Then, use **startAbility** to start the application. In this way, the application can be started without specifying the bundle name. To start the third-party application successfully, you need to install **PulledUpApplication** in the **dependence** directory. You can also download this project and set the startup parameters to start a third-party application.
+
+To start a system application from the web page, you need to intercept the page loading using **onLoadIntercept**. Then, you can set the parameters of **Want** to the configuration of the corresponding system application, and use **startAbility** to start the system application. In addition, the system application can also be started using the **Picker** and APIs provided by the system in a specific scenario.
+
+To jump from a web page to the details page in AppGallery, you need to intercept the page loading using **onLoadIntercept** and then use the AppGallery recommendation function of Store Kit. This function provides the **loadProduct** API to load the details page on AppGallery.
+
+To start an application on another device from the web page, you need to intercept the page loading using **onLoadIntercept**, use **getAvailableDeviceListSync** to obtain the list of trusted devices, and set the **deviceId** parameter of **want**. In this case, note that you need to log in to the same HUAWEI ID on multiple devices, connect to the same Wi-Fi network, and enable Bluetooth.
+
+## Required Permissions
+
+* **DISTRIBUTED_DATASYNC**, which allows data to be exchanged between devices.
+
+## Constraints
+
+1. The sample app is supported only on Huawei phones running the standard system.
+2. The HarmonyOS version must be HarmonyOS NEXT Developer Beta1 or later.
+3. The DevEco Studio version must be DevEco Studio NEXT Developer Beta1 or later.
+4. The HarmonyOS SDK version must be HarmonyOS NEXT Developer Beta1 or later.
diff --git a/dependence/PulledUpApplication/entry/src/main/ets/pages/test.json5 b/dependence/PulledUpApplication/entry/src/main/ets/pages/test.json5
deleted file mode 100644
index e442601637dd61888902f7350d9b43c6a00de3d6..0000000000000000000000000000000000000000
--- a/dependence/PulledUpApplication/entry/src/main/ets/pages/test.json5
+++ /dev/null
@@ -1,31 +0,0 @@
-{
- "module": {
- // ...
- "abilities": [
- {
- // ...
- "skills": [
- {
- "entities": [
- // ...
- "entity.system.browsable"
- ],
- "actions": [
- // ...
- "ohos.want.action.viewData",
- ],
- "uris": [
- {
- "scheme": "appScheme", // scheme可以自定义
- "host": "www.test.com", // host须配置关联的域名
- "port": "80", // port可选
- "path": "path1" // path可选,为了避免匹配到多个应用,建议配置该字段
- }
- ]
- }
- ]
- }
- ],
- // ...
- }
-}
\ No newline at end of file
diff --git a/dependence/PulledUpApplication/entry/src/main/module.json5 b/dependence/PulledUpApplication/entry/src/main/module.json5
index bd9e2fdf74acc29932420bca4363324fcf9895d2..2d6965f3b53f5d88b80491517c5ad4f463112e2e 100644
--- a/dependence/PulledUpApplication/entry/src/main/module.json5
+++ b/dependence/PulledUpApplication/entry/src/main/module.json5
@@ -24,12 +24,21 @@
"skills": [
{
"entities": [
+ "entity.system.browsable",
"entity.system.home",
"entity.system.default"
],
"actions": [
"action.system.home",
"ohos.want.action.viewData",
+ ],
+ "uris": [
+ {
+ "scheme": "appScheme",
+ "host": "www.test.com",
+ "port": "80",
+ "path": "path1"
+ }
]
}
]
diff --git a/entry/src/main/ets/common/Constants.ets b/entry/src/main/ets/common/Constants.ets
index 9359fb52f0b775ca9aa19d2c922a205e2bcbcce6..dfe64f568cae7f9e83cf3ae0522e18a34dc68b6f 100644
--- a/entry/src/main/ets/common/Constants.ets
+++ b/entry/src/main/ets/common/Constants.ets
@@ -38,7 +38,6 @@ export class Constants {
* Web page router chinese name.
*/
static readonly WEB_PAGE_CHINESE: string = 'Web页面';
-
/**
* Original web page link.
*/
@@ -48,4 +47,8 @@ export class Constants {
* Original web page link.
*/
static readonly WEB_PAGE_ADDRESS: string = 'resource://rawfile/index1.html';
+
+ static readonly SYSTEM_LANGUAGE_KEY: string = 'systemLanguage';
+ static readonly CHINESE_LANGUAGE: string = 'zh-Hans-CN';
+ static readonly ENGLISH_LANGUAGE: string = 'en-Latn-CN';
}
\ No newline at end of file
diff --git a/entry/src/main/ets/entryability/EntryAbility.ets b/entry/src/main/ets/entryability/EntryAbility.ets
index aff72cacf93d162fcb5b936ca6b49fef5955a079..4d51dbd0d15479604343a3b2d09369b8438c901f 100644
--- a/entry/src/main/ets/entryability/EntryAbility.ets
+++ b/entry/src/main/ets/entryability/EntryAbility.ets
@@ -13,14 +13,25 @@
* limitations under the License.
*/
-import { abilityAccessCtrl, AbilityConstant, bundleManager, Permissions, UIAbility, Want } from '@kit.AbilityKit';
+import {
+ abilityAccessCtrl,
+ AbilityConstant,
+ bundleManager,
+ Configuration,
+ Permissions,
+ UIAbility,
+ Want
+} from '@kit.AbilityKit';
import { hilog } from '@kit.PerformanceAnalysisKit';
import { window } from '@kit.ArkUI';
+import { Constants } from '../common/Constants';
export default class EntryAbility extends UIAbility {
onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void {
this.checkPermissions();
hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate');
+ AppStorage.setOrCreate(Constants.SYSTEM_LANGUAGE_KEY, this.context.config.language);
+ console.log(`language is ${this.context.config.language}`)
}
onDestroy(): void {
@@ -55,6 +66,13 @@ export default class EntryAbility extends UIAbility {
hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground');
}
+ onConfigurationUpdate(newConfig: Configuration): void {
+ if (AppStorage.get(Constants.SYSTEM_LANGUAGE_KEY) !== newConfig.language) {
+ AppStorage.setOrCreate(Constants.SYSTEM_LANGUAGE_KEY, newConfig.language)
+
+ }
+ }
+
async checkPermissions(): Promise