1/* 2 * Copyright (C) 2024 Huawei Device Co., Ltd. 3 * Licensed under the Apache License, Version 2.0 (the "License"); 4 * you may not use this file except in compliance with the License. 5 * You may obtain a copy of the License at 6 * 7 * http://www.apache.org/licenses/LICENSE-2.0 8 * 9 * Unless required by applicable law or agreed to in writing, software 10 * distributed under the License is distributed on an "AS IS" BASIS, 11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 * See the License for the specific language governing permissions and 13 * limitations under the License. 14 */ 15import { appManager, common, Want } from '@kit.AbilityKit'; 16import { hilog } from '@kit.PerformanceAnalysisKit'; 17import UIAbility from '@ohos.app.ability.UIAbility'; 18import { BusinessError } from '@kit.BasicServicesKit'; 19import { systemParameterEnhance } from '@kit.BasicServicesKit'; 20function sleep(time: number){ 21 return new Promise<void>((resolve) => setTimeout(resolve, time)) 22} 23 24@Entry 25@Component 26struct Index { 27 aboutToAppear(): void { 28 try { 29 let info: string = systemParameterEnhance.getSync('persist.sys.abilityms.multi_process_model'); 30 console.log('1111',JSON.stringify(info)); 31 } catch(e) { 32 console.log('getSync unexpected error: ' + e); 33 } 34 } 35 @State message: string = 'appA'; 36//获取上下文对象 37 context=getContext(this) as common.UIAbilityContext 38 build() { 39 Column({space:5}){ 40 Text(this.message) 41 .id('appA') 42 .fontSize(50) 43 .fontWeight(FontWeight.Bold) 44 .alignRules({ 45 center: { anchor: '__container__', align: VerticalAlign.Center }, 46 middle: { anchor: '__container__', align: HorizontalAlign.Center } 47 }) 48 Button('仅配置action') 49 .id('TestCase4') 50 .onClick(() => { 51 let want: Want = { 52 parameters: { 53 'ohos.ability.params.showDefaultPicker':true, 54 55 56 }, 57 action:'-~!@#$ %^&*' 58 } 59 this.context.startAbility(want) 60 .then(() => { 61 hilog.info(0x0000, 'startAbility', '%{public}s', 'success startAbility1'); 62 }) 63 .catch((error: BusinessError) => { 64 hilog.info(0x0000, 'startAbility', '%{public}s', 'startAbility1 error'); 65 }) 66 67 }) 68 69 70 } 71 .height('100%') 72 .width('100%') 73 } 74}