RM新时代网站-首页

0
  • 聊天消息
  • 系統(tǒng)消息
  • 評(píng)論與回復(fù)
登錄后你可以
  • 下載海量資料
  • 學(xué)習(xí)在線課程
  • 觀看技術(shù)視頻
  • 寫文章/發(fā)帖/加入社區(qū)
會(huì)員中心
創(chuàng)作中心

完善資料讓更多小伙伴認(rèn)識(shí)你,還能領(lǐng)取20積分哦,立即完善>

3天內(nèi)不再提示

鴻蒙開(kāi)發(fā)Ability Kit程序框架服務(wù):FA模型綁定Stage模型ServiceExtensionAbility

jf_46214456 ? 來(lái)源:jf_46214456 ? 作者:jf_46214456 ? 2024-06-25 10:43 ? 次閱讀

FA模型綁定Stage模型ServiceExtensionAbility

本文介紹FA模型的三種應(yīng)用組件如何綁定Stage模型的ServiceExtensionAbility組件。
開(kāi)發(fā)前請(qǐng)熟悉鴻蒙開(kāi)發(fā)指導(dǎo)文檔 :[gitee.com/li-shizhen-skin/harmony-os/blob/master/README.md]

PageAbility關(guān)聯(lián)訪問(wèn)ServiceExtensionAbility

PageAbility關(guān)聯(lián)訪問(wèn)ServiceExtensionAbility和PageAbility關(guān)聯(lián)訪問(wèn)ServiceAbility的方式完全相同。

import featureAbility from '@ohos.ability.featureAbility';
import common from '@ohos.app.ability.common';
import Want from '@ohos.app.ability.Want';
import { BusinessError } from '@ohos.base';
import hilog from '@ohos.hilog';

const TAG: string = 'PageInterflowFaAndStage';
const domain: number = 0xFF00;

@Entry
@Component
struct PageInterflowFaAndStage {
  build() {
    Column() {
      // ...
      List({ initialIndex: 0 }) {
        ListItem() {
          Row() {
            // ...
          }
          .onClick(() = > {
            let want: Want = {
              bundleName: 'ohos.samples.etsclock',
              abilityName: 'MainAbility'
            };
            featureAbility.startAbility({ want }).then((code) = > {
              hilog.info(domain, TAG, 'Ability verify code: ' + JSON.stringify(code));
            }).catch((error: BusinessError) = > {
              hilog.error(domain, TAG, 'Ability failed: ' + JSON.stringify(error));
            });
            let serviceWant: Want = {
              bundleName: 'com.samples.stagemodelabilityinteraction',
              abilityName: 'ServiceExtAbility'
            };
            let faConnect: common.ConnectOptions = {
              onConnect: (elementName, proxy) = > {
                hilog.info(domain, TAG, "FaConnection onConnect called.");
              },
              onDisconnect: (elementName) = > {
                hilog.info(domain, TAG, "FaConnection onDisconnect called.");
              },
              onFailed: (code) = > {
                hilog.info(domain, TAG, "FaConnection onFailed code is: " + code);
              }
            };
            let connectionId = featureAbility.connectAbility(serviceWant, faConnect);
          })
        }
        // ...
      }
      // ...
    }
    // ...
  }
}

ServiceAbility/DataAbility關(guān)聯(lián)訪問(wèn)ServiceExtensionAbility

ServiceAbility/DataAbility關(guān)聯(lián)訪問(wèn)ServiceExtensionAbility和ServiceAbility/DataAbility關(guān)聯(lián)訪問(wèn)ServiceAbility的方式完全相同。
HarmonyOSOpenHarmony鴻蒙文檔籽料:mau123789是v直接拿

搜狗高速瀏覽器截圖20240326151547.png

import type common from '@ohos.app.ability.common';
import particleAbility from '@ohos.ability.particleAbility';
import type Want from '@ohos.app.ability.Want';
import type { BusinessError } from '@ohos.base';
import hilog from '@ohos.hilog';

const TAG: string = '[Sample_FAModelAbilityDevelop]';
const domain: number = 0xFF00;

class ServiceAbilityStartUiAbility {
  onStart(): void {
    // 啟動(dòng)UIAbility
    let want: Want = {
      bundleName: 'ohos.samples.etsclock',
      abilityName: 'MainAbility'
    };
    particleAbility.startAbility({ want }).then(() = > {
      hilog.info(domain, TAG, 'ServiceAbilityStartUIAbility Start Ability successfully.');
    }).catch((error: BusinessError) = > {
      hilog.info(domain, TAG, 'ServiceAbilityStartUIAbility Ability failed: ' + JSON.stringify(error));
    });

    // 訪問(wèn)ServiceExtensionAbility
    let serviceWant: Want = {
      bundleName: 'com.samples.stagemodelabilityinteraction',
      abilityName: 'ServiceExtAbility'
    };
    let faConnect: common.ConnectOptions = {
      onConnect: (elementName, proxy) = > {
        hilog.info(domain, TAG, 'FaConnection onConnect called.');
      },
      onDisconnect: (elementName) = > {
        hilog.info(domain, TAG, 'FaConnection onDisconnect called.');
      },
      onFailed: (code) = > {
        hilog.info(domain, TAG, 'FaConnection onFailed code is: ' + code);
      }
    };
    let connectionId = particleAbility.connectAbility(serviceWant, faConnect);
    hilog.info(domain, TAG, 'ServiceAbilityStartUIAbility ServiceAbility onStart');
  }
};

export default new ServiceAbilityStartUiAbility();

審核編輯 黃宇

聲明:本文內(nèi)容及配圖由入駐作者撰寫或者入駐合作網(wǎng)站授權(quán)轉(zhuǎn)載。文章觀點(diǎn)僅代表作者本人,不代表電子發(fā)燒友網(wǎng)立場(chǎng)。文章及其配圖僅供工程師學(xué)習(xí)之用,如有內(nèi)容侵權(quán)或者其他違規(guī)問(wèn)題,請(qǐng)聯(lián)系本站處理。 舉報(bào)投訴
  • 框架
    +關(guān)注

    關(guān)注

    0

    文章

    403

    瀏覽量

    17475
  • 模型
    +關(guān)注

    關(guān)注

    1

    文章

    3226

    瀏覽量

    48807
  • 鴻蒙
    +關(guān)注

    關(guān)注

    57

    文章

    2339

    瀏覽量

    42805
收藏 人收藏

    評(píng)論

    相關(guān)推薦

    鴻蒙開(kāi)發(fā)Ability Kit程序框架服務(wù):API切換概述 API切換

    FA模型Stage模型由于線程模型和進(jìn)程模型的差異,部分接口僅在
    的頭像 發(fā)表于 06-28 16:23 ?333次閱讀
    <b class='flag-5'>鴻蒙</b><b class='flag-5'>開(kāi)發(fā)</b><b class='flag-5'>Ability</b> <b class='flag-5'>Kit</b><b class='flag-5'>程序</b><b class='flag-5'>框架</b><b class='flag-5'>服務(wù)</b>:API切換概述 API切換

    鴻蒙開(kāi)發(fā)Ability Kit程序框架服務(wù):ServiceAbility切換 組件切換

    FA模型中的ServiceAbility對(duì)應(yīng)Stage模型中的ServiceExtensionAbility。
    的頭像 發(fā)表于 06-28 10:24 ?322次閱讀
    <b class='flag-5'>鴻蒙</b><b class='flag-5'>開(kāi)發(fā)</b><b class='flag-5'>Ability</b> <b class='flag-5'>Kit</b><b class='flag-5'>程序</b><b class='flag-5'>框架</b><b class='flag-5'>服務(wù)</b>:ServiceAbility切換 組件切換

    鴻蒙開(kāi)發(fā)Ability Kit程序框架服務(wù)FA模型切換Stage模型指導(dǎo) module的切換

    FA模型切換到Stage模型時(shí),開(kāi)發(fā)者需要將config.json文件module標(biāo)簽下的配置遷移到module.json5配置文件mod
    的頭像 發(fā)表于 06-27 14:16 ?447次閱讀
    <b class='flag-5'>鴻蒙</b><b class='flag-5'>開(kāi)發(fā)</b><b class='flag-5'>Ability</b> <b class='flag-5'>Kit</b><b class='flag-5'>程序</b><b class='flag-5'>框架</b><b class='flag-5'>服務(wù)</b>:<b class='flag-5'>FA</b><b class='flag-5'>模型</b>切換<b class='flag-5'>Stage</b><b class='flag-5'>模型</b>指導(dǎo) module的切換

    鴻蒙開(kāi)發(fā)Ability Kit程序框架服務(wù)FA模型切換Stage模型指導(dǎo) app和deviceConfig的切換

    為了便于開(kāi)發(fā)者維護(hù)應(yīng)用級(jí)別的屬性配置,Stage模型將config.json中的app和deviceConfig標(biāo)簽提取到了app.json5中進(jìn)行配置,并對(duì)部分標(biāo)簽名稱進(jìn)行了修改,具體差異見(jiàn)下表。
    的頭像 發(fā)表于 06-27 10:01 ?345次閱讀
    <b class='flag-5'>鴻蒙</b><b class='flag-5'>開(kāi)發(fā)</b><b class='flag-5'>Ability</b> <b class='flag-5'>Kit</b><b class='flag-5'>程序</b><b class='flag-5'>框架</b><b class='flag-5'>服務(wù)</b>:<b class='flag-5'>FA</b><b class='flag-5'>模型</b>切換<b class='flag-5'>Stage</b><b class='flag-5'>模型</b>指導(dǎo) app和deviceConfig的切換

    鴻蒙開(kāi)發(fā)Ability Kit程序框架服務(wù)FA模型切換Stage模型概述

    本文介紹如何將一個(gè)FA模型開(kāi)發(fā)的聲明式范式應(yīng)用切換到Stage模型
    的頭像 發(fā)表于 06-26 14:40 ?336次閱讀
    <b class='flag-5'>鴻蒙</b><b class='flag-5'>開(kāi)發(fā)</b><b class='flag-5'>Ability</b> <b class='flag-5'>Kit</b><b class='flag-5'>程序</b><b class='flag-5'>框架</b><b class='flag-5'>服務(wù)</b>:<b class='flag-5'>FA</b><b class='flag-5'>模型</b>切換<b class='flag-5'>Stage</b><b class='flag-5'>模型</b>概述

    鴻蒙開(kāi)發(fā)Ability Kit程序框架服務(wù)Stage模型啟動(dòng)FA模型PageAbility

    本小節(jié)介紹Stage模型的兩種應(yīng)用組件如何啟動(dòng)FA模型的PageAbility組件。
    的頭像 發(fā)表于 06-26 09:50 ?360次閱讀
    <b class='flag-5'>鴻蒙</b><b class='flag-5'>開(kāi)發(fā)</b><b class='flag-5'>Ability</b> <b class='flag-5'>Kit</b><b class='flag-5'>程序</b><b class='flag-5'>框架</b><b class='flag-5'>服務(wù)</b>:<b class='flag-5'>Stage</b><b class='flag-5'>模型</b>啟動(dòng)<b class='flag-5'>FA</b><b class='flag-5'>模型</b>PageAbility

    鴻蒙開(kāi)發(fā)Ability Kit程序框架服務(wù)Stage模型綁定FA模型ServiceAbility

    本小節(jié)介紹Stage模型的兩種應(yīng)用組件如何綁定FA模型ServiceAbility組件。
    的頭像 發(fā)表于 06-25 21:47 ?301次閱讀
    <b class='flag-5'>鴻蒙</b><b class='flag-5'>開(kāi)發(fā)</b><b class='flag-5'>Ability</b> <b class='flag-5'>Kit</b><b class='flag-5'>程序</b><b class='flag-5'>框架</b><b class='flag-5'>服務(wù)</b>:<b class='flag-5'>Stage</b><b class='flag-5'>模型</b><b class='flag-5'>綁定</b><b class='flag-5'>FA</b><b class='flag-5'>模型</b>ServiceAbility

    鴻蒙開(kāi)發(fā)Ability Kit程序框架服務(wù)FA模型啟動(dòng)Stage模型UIAbility

    本文介紹FA模型的三種應(yīng)用組件如何啟動(dòng)Stage模型的UIAbility組件。
    的頭像 發(fā)表于 06-25 16:00 ?359次閱讀
    <b class='flag-5'>鴻蒙</b><b class='flag-5'>開(kāi)發(fā)</b><b class='flag-5'>Ability</b> <b class='flag-5'>Kit</b><b class='flag-5'>程序</b><b class='flag-5'>框架</b><b class='flag-5'>服務(wù)</b>:<b class='flag-5'>FA</b><b class='flag-5'>模型</b>啟動(dòng)<b class='flag-5'>Stage</b><b class='flag-5'>模型</b>UIAbility

    鴻蒙開(kāi)發(fā)Ability Kit程序框架服務(wù)FA模型訪問(wèn)Stage模型DataShareExtensionAbility

    無(wú)論FA模型還是Stage模型,數(shù)據(jù)讀寫功能都包含客戶端和服務(wù)端兩部分。
    的頭像 發(fā)表于 06-25 14:30 ?384次閱讀
    <b class='flag-5'>鴻蒙</b><b class='flag-5'>開(kāi)發(fā)</b><b class='flag-5'>Ability</b> <b class='flag-5'>Kit</b><b class='flag-5'>程序</b><b class='flag-5'>框架</b><b class='flag-5'>服務(wù)</b>:<b class='flag-5'>FA</b><b class='flag-5'>模型</b>訪問(wèn)<b class='flag-5'>Stage</b><b class='flag-5'>模型</b>DataShareExtensionAbility

    鴻蒙開(kāi)發(fā)Ability Kit程序框架服務(wù)FA模型Stage模型應(yīng)用組件互通綜述

    FA模型Stage模型是兩套不同的應(yīng)用模型,他們擁有各自的組件。FA
    的頭像 發(fā)表于 06-24 16:43 ?516次閱讀
    <b class='flag-5'>鴻蒙</b><b class='flag-5'>開(kāi)發(fā)</b><b class='flag-5'>Ability</b> <b class='flag-5'>Kit</b><b class='flag-5'>程序</b><b class='flag-5'>框架</b><b class='flag-5'>服務(wù)</b>:<b class='flag-5'>FA</b><b class='flag-5'>模型</b>與<b class='flag-5'>Stage</b><b class='flag-5'>模型</b>應(yīng)用組件互通綜述

    鴻蒙Ability Kit程序框架服務(wù))【組件啟動(dòng)規(guī)則(Stage模型)】

    組件啟動(dòng)規(guī)則(Stage模型) 啟動(dòng)組件是指一切啟動(dòng)或連接應(yīng)用組件的行為: 啟動(dòng)UIAbility、ServiceExtensionAbility、DataShareExtensionAbility
    的頭像 發(fā)表于 06-10 18:47 ?913次閱讀
    <b class='flag-5'>鴻蒙</b><b class='flag-5'>Ability</b> <b class='flag-5'>Kit</b>(<b class='flag-5'>程序</b><b class='flag-5'>框架</b><b class='flag-5'>服務(wù)</b>)【組件啟動(dòng)規(guī)則(<b class='flag-5'>Stage</b><b class='flag-5'>模型</b>)】

    鴻蒙Ability Kit程序框架服務(wù))【AbilityServiceExtensionAbility通信】

    本示例展示通過(guò)[IDL的方式]和?[@ohos.rpc]?等接口實(shí)現(xiàn)了AbilityServiceExtensionAbility之間的通信。
    的頭像 發(fā)表于 06-05 09:28 ?480次閱讀
    <b class='flag-5'>鴻蒙</b><b class='flag-5'>Ability</b> <b class='flag-5'>Kit</b>(<b class='flag-5'>程序</b><b class='flag-5'>框架</b><b class='flag-5'>服務(wù)</b>)【<b class='flag-5'>Ability</b>與<b class='flag-5'>ServiceExtensionAbility</b>通信】

    鴻蒙Ability Kit程序框架服務(wù))【ServiceExtensionAbility

    [ServiceExtensionAbility]是SERVICE類型的ExtensionAbility組件,提供后臺(tái)服務(wù)能力,其內(nèi)部持有了一個(gè)[ServiceExtensionContext],通過(guò)[ServiceExtensionContext]提供了豐富的接口供外部
    的頭像 發(fā)表于 06-04 14:50 ?1197次閱讀
    <b class='flag-5'>鴻蒙</b><b class='flag-5'>Ability</b> <b class='flag-5'>Kit</b>(<b class='flag-5'>程序</b><b class='flag-5'>框架</b><b class='flag-5'>服務(wù)</b>)【<b class='flag-5'>ServiceExtensionAbility</b>】

    鴻蒙Ability Kit程序框架服務(wù))【Ability內(nèi)頁(yè)面間的跳轉(zhuǎn)】

    基于Stage模型下的Ability開(kāi)發(fā),實(shí)現(xiàn)Ability內(nèi)頁(yè)面間的跳轉(zhuǎn)和數(shù)據(jù)傳遞。
    的頭像 發(fā)表于 06-03 20:43 ?296次閱讀
    <b class='flag-5'>鴻蒙</b><b class='flag-5'>Ability</b> <b class='flag-5'>Kit</b>(<b class='flag-5'>程序</b><b class='flag-5'>框架</b><b class='flag-5'>服務(wù)</b>)【<b class='flag-5'>Ability</b>內(nèi)頁(yè)面間的跳轉(zhuǎn)】

    鴻蒙應(yīng)用模型:【Ability Kit】簡(jiǎn)介

    Ability Kit程序框架服務(wù))提供了應(yīng)用程序開(kāi)發(fā)
    的頭像 發(fā)表于 05-29 14:41 ?634次閱讀
    <b class='flag-5'>鴻蒙</b>應(yīng)用<b class='flag-5'>模型</b>:【<b class='flag-5'>Ability</b> <b class='flag-5'>Kit</b>】簡(jiǎn)介
    RM新时代网站-首页