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 */ 15 16import { BusinessError } from '@ohos.base'; 17import Want from '@ohos.app.ability.Want'; 18import common from '@ohos.app.ability.common'; 19import { logger } from '@ohos/common/src/main/ets/util/Logger'; 20 21@Component 22export struct ProcessMessage { 23 24 build() { 25 Column() { 26 Button() { 27 Text($r('app.string.process')) 28 .fontSize(16) 29 .fontColor(Color.White) 30 } 31 .width('100%') 32 .height(50) 33 .type(ButtonType.Capsule) 34 .onClick(() => { 35 let context: common.UIAbilityContext | undefined = AppStorage.get('context'); 36 let want: Want = { 37 bundleName: "com.samples.process_message", 38 abilityName: "EntryAbility", 39 }; 40 context && context.startAbility(want, (err: BusinessError) => { 41 if (err.code) { 42 logger.error('StartAbility', `Failed to startAbility. Code: ${err.code}, message: ${err.message}`); 43 } 44 }); 45 }) 46 } 47 .width('100%') 48 .height('100%') 49 .justifyContent(FlexAlign.Center) 50 .alignItems(HorizontalAlign.Center) 51 } 52}