harmony 鸿蒙want.h

  • 2025-06-12
  • 浏览 (5)

want.h

Overview

Want is a carrier for information transfer between objects (application components). Want can be used as a parameter of startAbility to specify a startup target and information that needs to be carried during startup, for example, bundleName and abilityName, which respectively indicate the bundle name of the target ability and the ability name in the bundle. When ability A needs to start ability B and transfer some data to ability B, it can use Want a carrier to transfer the data.

File to include:

Library: libability_base_want.so

System capability: SystemCapability.Ability.AbilityBase

Since: 15

Related module: AbilityBase

Summary

Files

Name Description
want.h Declare Want-related capabilities.
File to include:
Library: libability_base_want.so

Structs

Name Description
AbilityBase_Element {
char* bundleName;
char* moduleName;
char* abilityName;
}
Element struct.
AbilityBase_Want Want struct.

Functions

Name Description
AbilityBase_Want* OH_AbilityBase_CreateWant(AbilityBase_Element element) Creates Want.
AbilityBase_ErrorCode OH_AbilityBase_DestroyWant(AbilityBase_Want* want) Destroys Want. Want cannot be used after being destroyed. Otherwise, undefined behavior may occur.
AbilityBase_ErrorCode OH_AbilityBase_SetWantElement(AbilityBase_Want* want, AbilityBase_Element element) Sets the Element struct, which consists of bundleName, moduleName, and abilityName in Want.
AbilityBase_ErrorCode OH_AbilityBase_GetWantElement(AbilityBase_Want* want, AbilityBase_Element* element) Obtains the Element struct, which consists of bundleName, moduleName, and abilityName in Want.
AbilityBase_ErrorCode OH_AbilityBase_SetWantCharParam(AbilityBase_Want* want, const char* key, const char* value) Sets Param in Want. For details about Param, see parameters in Want.
AbilityBase_ErrorCode OH_AbilityBase_GetWantCharParam(AbilityBase_Want* want, const char* key, char* value, size_t valueSize) Obtains Param set by OH_AbilityBase_SetWantCharParam in Want.
AbilityBase_ErrorCode OH_AbilityBase_AddWantFd(AbilityBase_Want* want, const char* key, int32_t fd) Adds a Want file descriptor. The file descriptor can be obtained through fs.open.
AbilityBase_ErrorCode OH_AbilityBase_GetWantFd(AbilityBase_Want* want, const char* key, int32_t* fd) Obtains a Want file descriptor.
AbilityBase_ErrorCode OH_AbilityBase_SetWantUri(AbilityBase_Want* want, const char* uri) Sets uri in Want. For details about uri, see uri in Want.
AbilityBase_ErrorCode OH_AbilityBase_GetWantUri(AbilityBase_Want* want, char* uri, size_t uriSize) Obtains uri set in Want. For details about uri, see uri in Want.
AbilityBase_ErrorCode OH_AbilityBase_SetWantInt32Param(AbilityBase_Want* want, const char* key, int32_t value) Sets a value of the int32_t type in Want.
AbilityBase_ErrorCode OH_AbilityBase_GetWantInt32Param(AbilityBase_Want* want, const char* key, int32_t* value) Obtains a value of the int32_t type set in Want.
AbilityBase_ErrorCode OH_AbilityBase_SetWantBoolParam(AbilityBase_Want* want, const char* key, bool value) Sets a value of the bool type in Want.
AbilityBase_ErrorCode OH_AbilityBase_GetWantBoolParam(AbilityBase_Want* want, const char* key, bool* value) Obtains a value of the bool type set in Want.
AbilityBase_ErrorCode OH_AbilityBase_SetWantDoubleParam(AbilityBase_Want* want, const char* key, double value) Sets a value of the double type in Want.
AbilityBase_ErrorCode OH_AbilityBase_GetWantDoubleParam(AbilityBase_Want* want, const char* key, double* value) Obtains a value of the double type set in Want.

你可能感兴趣的鸿蒙文章

harmony 鸿蒙Ability Kit

harmony 鸿蒙AbilityAccessControl

harmony 鸿蒙AbilityBase

harmony 鸿蒙AbilityBase_Element

harmony 鸿蒙AbilityRuntime

harmony 鸿蒙bundle

harmony 鸿蒙OH_NativeBundle_ApplicationInfo

harmony 鸿蒙OH_NativeBundle_ElementName

harmony 鸿蒙ability_access_control.h

harmony 鸿蒙ability_base_common.h

0  赞