鴻蒙OS 開發(fā)CLUSTER相關(guān)應(yīng)用

2020-09-18 17:55 更新

場(chǎng)景介紹

通常在汽車使用過程中,駕駛員需要設(shè)置儀表屏亮度、時(shí)間單位等參數(shù),將電臺(tái)、音樂等娛樂數(shù)據(jù)或?qū)Ш綌?shù)據(jù)顯示在儀表屏上,因此 HarmonyOS 提供了和儀表交互相關(guān)的接口,供三方開發(fā)者開發(fā)儀表設(shè)置、顯示等相關(guān)應(yīng)用。

說(shuō)明

該功能與具體的車廠車型相關(guān),部分低配車型可能不具備該項(xiàng)功能。

接口說(shuō)明

目前Cluster提供的功能有如下表所示:

接口名 描述
getClusterSignal() 獲取指定Cluster信號(hào)值。
setClusterActuator() 設(shè)置指定Cluster執(zhí)行器值。
sendClusterSignal() 發(fā)送指定字節(jié)數(shù)組類型的Cluster信號(hào)請(qǐng)求信息。
subscribeClusterSignal() 訂閱指定Cluster信號(hào)。
subscribeBatchProperties() 批量訂閱Cluster信號(hào)。
unsubscribeClusterSignal() 取消訂閱指定的Cluster信號(hào)。
unsubscribeClusterSignalAll() 取消所有訂閱的Cluster信號(hào)。

開發(fā)步驟

  1. 根據(jù)不同管理入口類,調(diào)對(duì)應(yīng)接口。

   // 設(shè)置Cluster屬性值
   String propId = ClusterManager.ID_CLUSTER_SETTINGS_BRIGHTNESS;
   ClusterActuatorCallback callback = new ClusterActuatorCallback() {
       @Override
       public void onErrorActuator(String propId, int errorCode) {}
   };
   boolean result = false;
   byte[] value = new byte[1];
   try {
        ClusterManager.sendClusterSignal(propId, callback, value);
        result = true;
   } catch (RemoteException | IllegalArgumentException | UnsupportedOperationException e) {
        result = false;
   }
以上內(nèi)容是否對(duì)您有幫助:
在線筆記
App下載
App下載

掃描二維碼

下載編程獅App

公眾號(hào)
微信公眾號(hào)

編程獅公眾號(hào)