1# AbilityRuntime 2 3 4## Overview 5 6The AbilityRuntime module provides capabilities related to the ability framework. 7 8**System capability**: SystemCapability.Ability.AbilityRuntime.Core 9 10**Since**: 13 11 12 13## Summary 14 15 16### Files 17 18| Name| Description| 19| -------- | -------- | 20| [ability_runtime_common.h](ability__runtime__common_8h.md) | Declares the error codes of the ability framework.<br>**File to include**: <AbilityKit/ability_runtime/ability_runtime_common.h><br>**Library**: libability_runtime.so| 21| [application_context.h](application__context_8h.md) | Declares the context capability at the application level.<br>**File to include**: <AbilityKit/ability_runtime/application_context.h><br>**Library**: libability_runtime.so| 22| [context_constant.h](context__constant_8h.md) | Declares the context-related enums.<br>**File to include**: <AbilityKit/ability_runtime/context_constant.h><br>**Library**: libability_runtime.so| 23 24### Enums 25 26| Name | Description | 27| ------------------------------------------------------------ | ---------------------- | 28| [AbilityRuntime_ErrorCode](#abilityruntime_errorcode) {<br> ABILITY_RUNTIME_ERROR_CODE_NO_ERROR = 0,<br> ABILITY_RUNTIME_ERROR_CODE_PERMISSION_DENIED = 201,<br> ABILITY_RUNTIME_ERROR_CODE_PARAM_INVALID = 401,<br> ABILITY_RUNTIME_ERROR_CODE_NOT_SUPPORTED = 801,<br> ABILITY_RUNTIME_ERROR_CODE_NO_SUCH_ABILITY = 16000001,<br> ABILITY_RUNTIME_ERROR_CODE_INCORRECT_ABILITY_TYPE = 16000002,<br> ABILITY_RUNTIME_ERROR_CODE_CROWDTEST_EXPIRED = 16000008,<br> ABILITY_RUNTIME_ERROR_CODE_WUKONG_MODE = 16000009,<br> ABILITY_RUNTIME_ERROR_CODE_CONTEXT_NOT_EXIST = 16000011,<br> ABILITY_RUNTIME_ERROR_CODE_CONTROLLED = 16000012,<br> ABILITY_RUNTIME_ERROR_CODE_EDM_CONTROLLED = 16000013,<br> ABILITY_RUNTIME_ERROR_CODE_CROSS_APP = 16000018,<br> ABILITY_RUNTIME_ERROR_CODE_INTERNAL = 16000050,<br> ABILITY_RUNTIME_ERROR_CODE_NOT_TOP_ABILITY = 16000053,<br/>} | Enumerates the error codes used by the ability framework. | 29| [AbilityRuntime_AreaMode](#abilityruntime_areamode) {<br> ABILITY_RUNTIME_AREA_MODE_EL1 = 0,<br> ABILITY_RUNTIME_AREA_MODE_EL2 = 1,<br> ABILITY_RUNTIME_AREA_MODE_EL3 = 2,<br> ABILITY_RUNTIME_AREA_MODE_EL4 = 3,<br> ABILITY_RUNTIME_AREA_MODE_EL5 = 4<br>} | Enumerates the data encryption levels. | 30 31### Functions 32 33| Name| Description| 34| -------- | -------- | 35| [AbilityRuntime_ErrorCode](#abilityruntime_errorcode) [OH_AbilityRuntime_ApplicationContextGetCacheDir](#oh_abilityruntime_applicationcontextgetcachedir)(char* buffer, int32_t bufferSize, int32_t* writeLength) | Obtains the application-level cache directory.| 36| [AbilityRuntime_ErrorCode](#abilityruntime_errorcode) [OH_AbilityRuntime_ApplicationContextGetAreaMode](#oh_abilityruntime_applicationcontextgetareamode)([AbilityRuntime_AreaMode](#abilityruntime_areamode)* areaMode) | Obtains the application-level data encryption level.| 37| [AbilityRuntime_ErrorCode](#abilityruntime_errorcode) [OH_AbilityRuntime_ApplicationContextGetBundleName](#oh_abilityruntime_applicationcontextgetbundlename)(char* buffer, int32_t bufferSize, int32_t* writeLength) | Obtains the bundle name of the application.| 38| [AbilityRuntime_ErrorCode](#abilityruntime_errorcode) [OH_AbilityRuntime_ApplicationContextGetTempDir](#oh_abilityruntime_applicationcontextgettempdir)(char* buffer, const int32_t bufferSize, int32_t* writeLength) | Obtains the application-level temporary file directory.| 39| [AbilityRuntime_ErrorCode](#abilityruntime_errorcode) [OH_AbilityRuntime_ApplicationContextGetFilesDir](#oh_abilityruntime_applicationcontextgetfilesdir)(char* buffer, const int32_t bufferSize, int32_t* writeLength) | Obtains the application-level common file directory.| 40| [AbilityRuntime_ErrorCode](#abilityruntime_errorcode) [OH_AbilityRuntime_ApplicationContextGetDatabaseDir](#oh_abilityruntime_applicationcontextgetdatabasedir)(char* buffer, const int32_t bufferSize, int32_t* writeLength) | Obtains the application-level database file directory.| 41| [AbilityRuntime_ErrorCode](#abilityruntime_errorcode) [OH_AbilityRuntime_ApplicationContextGetPreferencesDir](#oh_abilityruntime_applicationcontextgetpreferencesdir)(char* buffer, const int32_t bufferSize, int32_t* writeLength) | Obtains the application-level preferences file directory.| 42| [AbilityRuntime_ErrorCode](#abilityruntime_errorcode) [OH_AbilityRuntime_ApplicationContextGetBundleCodeDir](#oh_abilityruntime_applicationcontextgetbundlecodedir)(char* buffer, const int32_t bufferSize, int32_t* writeLength) | Obtains the application-level installation file directory.| 43| [AbilityRuntime_ErrorCode](#abilityruntime_errorcode) [OH_AbilityRuntime_ApplicationContextGetDistributedFilesDir](#oh_abilityruntime_applicationcontextgetdistributedfilesdir)(char* buffer, const int32_t bufferSize, int32_t* writeLength) | Obtains the application-level distributed file directory.| 44| [AbilityRuntime_ErrorCode](#abilityruntime_errorcode) [OH_AbilityRuntime_ApplicationContextGetCloudFileDir](#oh_abilityruntime_applicationcontextgetcloudfiledir)(char* buffer, const int32_t bufferSize, int32_t* writeLength) | Obtains the application-level cloud file directory.| 45| [AbilityRuntime_ErrorCode](#abilityruntime_errorcode) [OH_AbilityRuntime_StartSelfUIAbility](#oh_abilityruntime_startselfuiability)([AbilityBase_Want](_ability_base.md#abilitybase_want) *want) | Starts the UIAbility of the current application.| 46 47## Enum Description 48 49### AbilityRuntime_ErrorCode 50 51``` 52enum AbilityRuntime_ErrorCode 53``` 54 55**Description** 56 57Enumerates the error codes used by the ability framework. 58 59**Since**: 13 60 61| Value | Description | 62| --------------------------------------------- | -------------- | 63| ABILITY_RUNTIME_ERROR_CODE_NO_ERROR | Operation successful. | 64| ABILITY_RUNTIME_ERROR_CODE_PARAM_INVALID | Invalid parameter. | 65| ABILITY_RUNTIME_ERROR_CODE_CONTEXT_NOT_EXIST | The context does not exist.| 66| ABILITY_RUNTIME_ERROR_CODE_PERMISSION_DENIED | Permission verification failed.<br>**Since**: 15| 67| ABILITY_RUNTIME_ERROR_CODE_NOT_SUPPORTED | The device type is not supported.<br>**Since**: 15| 68| ABILITY_RUNTIME_ERROR_CODE_NO_SUCH_ABILITY | The specified ability name does not exist.<br>**Since**: 15| 69| ABILITY_RUNTIME_ERROR_CODE_INCORRECT_ABILITY_TYPE | The ability type is incorrect.<br>**Since**: 15| 70| ABILITY_RUNTIME_ERROR_CODE_CROWDTEST_EXPIRED | The crowdtesting application expires.<br>**Since**: 15| 71| ABILITY_RUNTIME_ERROR_CODE_WUKONG_MODE | An ability cannot be started or stopped in Wukong mode.<br>**Since**: 15| 72| ABILITY_RUNTIME_ERROR_CODE_CONTROLLED | The application is under control.<br>**Since**: 15| 73| ABILITY_RUNTIME_ERROR_CODE_EDM_CONTROLLED | The application is under control by EDM.<br>**Since**: 15| 74| ABILITY_RUNTIME_ERROR_CODE_CROSS_APP | Redirection to third-party applications is not allowed in API versions later than 11.<br>**Since**: 15| 75| ABILITY_RUNTIME_ERROR_CODE_INTERNAL | Internal error.<br>**Since**: 15| 76| ABILITY_RUNTIME_ERROR_CODE_NOT_TOP_ABILITY | The application is not on top.<br>**Since**: 15| 77 78### AbilityRuntime_AreaMode 79 80``` 81enum AbilityRuntime_AreaMode 82``` 83 84**Description** 85 86Enumerates the data encryption levels. 87 88**Since**: 13 89 90| Value | Description | 91| ----------------------------- | ------------------------------------------------------------ | 92| ABILITY_RUNTIME_AREA_MODE_EL1 | For private files, such as alarms and wallpapers, the application can place them in a directory with the device-level encryption (EL1) to ensure that they can be accessed before the user enters the password.| 93| ABILITY_RUNTIME_AREA_MODE_EL2 | For sensitive files, such as personal privacy data, the application can place them in a directory with the user-level encryption (EL2).| 94| ABILITY_RUNTIME_AREA_MODE_EL3 | For step recording, file download, or music playback that needs to read, write, and create files when the screen is locked, the application can place these files in EL3.| 95| ABILITY_RUNTIME_AREA_MODE_EL4 | For files that are related to user security information and do not need to be read, written, or created when the screen is locked, the application can place them in EL4.| 96| ABILITY_RUNTIME_AREA_MODE_EL5 | By default, sensitive user privacy files cannot be read or written on the lock screen. If such files need to be read or written on the lock screen, you can call [Access](js-apis-screenLockFileManager.md#screenlockfilemanageracquireaccess) to apply for reading or writing files before the screen is locked or create new files that can be read and written after the screen is locked. It is more appropriate to place these files in EL5.| 97 98## Function Description 99 100 101### OH_AbilityRuntime_ApplicationContextGetCacheDir 102 103``` 104AbilityRuntime_ErrorCode OH_AbilityRuntime_ApplicationContextGetCacheDir(char* buffer, int32_t bufferSize, int32_t* writeLength) 105``` 106**Description** 107 108Obtains the application-level cache directory. 109 110**Since**: 13 111 112**Parameters** 113 114| Name| Description| 115| -------- | -------- | 116| buffer | Pointer to the buffer. The cache directory string is written to this area.| 117| bufferSize | Buffer size.| 118| writeLength | Pointer to the length of the string written to the buffer when **ABILITY_RUNTIME_ERROR_CODE_NO_ERROR** is returned.| 119 120**Returns** 121 122Returns **ABILITY_RUNTIME_ERROR_CODE_NO_ERROR** if the operation is successful. 123 124Returns **ABILITY_RUNTIME_ERROR_CODE_PARAM_INVALID** if the passed-in value of **buffer** or **writeLength** is null or the buffer size is less than the size of the string to be written. 125 126Returns **ABILITY_RUNTIME_ERROR_CODE_CONTEXT_NOT_EXIST** if the context of the current environment does not exist. For example, the application-level context does not exist in the [child process](c-apis-ability-childprocess.md) created by the application. 127 128### OH_AbilityRuntime_ApplicationContextGetAreaMode 129 130``` 131AbilityRuntime_ErrorCode OH_AbilityRuntime_ApplicationContextGetAreaMode(AbilityRuntime_AreaMode* areaMode) 132``` 133 134**Description** 135 136Obtains the application-level data encryption level. 137 138**Since**: 13 139 140**Parameters** 141 142| Name | Description | 143| -------- | ------------------------ | 144| areaMode | Pointer to the data encryption level.| 145 146**Returns** 147 148Returns **ABILITY_RUNTIME_ERROR_CODE_NO_ERROR** if the operation is successful. 149 150Returns **ABILITY_RUNTIME_ERROR_CODE_PARAM_INVALID** if **areaMode** is a null pointer. 151 152Returns **ABILITY_RUNTIME_ERROR_CODE_CONTEXT_NOT_EXIST** if the context of the current environment does not exist. For example, the application-level context does not exist in the [child process](c-apis-ability-childprocess.md) created by the application. 153 154### OH_AbilityRuntime_ApplicationContextGetBundleName 155 156``` 157AbilityRuntime_ErrorCode OH_AbilityRuntime_ApplicationContextGetBundleName(char* buffer, int32_t bufferSize, int32_t* writeLength) 158``` 159 160**Description** 161 162Obtains the bundle name of the application. 163 164**Since**: 13 165 166**Parameters** 167 168| Name | Description | 169| ----------- | ------------------------------------------------------------ | 170| buffer | Pointer to the buffer. The bundle name string is written to this area. | 171| bufferSize | Buffer size. | 172| writeLength | Pointer to the length of the string written to the buffer when **ABILITY_RUNTIME_ERROR_CODE_NO_ERROR** is returned.| 173 174**Returns** 175 176Returns **ABILITY_RUNTIME_ERROR_CODE_NO_ERROR** if the operation is successful. 177 178Returns **ABILITY_RUNTIME_ERROR_CODE_PARAM_INVALID** if the passed-in value of **buffer** or **writeLength** is null or the buffer size is less than the size of the string to be written. 179 180Returns **ABILITY_RUNTIME_ERROR_CODE_CONTEXT_NOT_EXIST** if the context of the current environment does not exist. For example, the application-level context does not exist in the [child process](c-apis-ability-childprocess.md) created by the application. 181 182### OH_AbilityRuntime_ApplicationContextGetTempDir 183 184``` 185AbilityRuntime_ErrorCode OH_AbilityRuntime_ApplicationContextGetTempDir(char* buffer, const int32_t bufferSize, int32_t* writeLength) 186``` 187 188**Description** 189 190Obtains the application-level temporary file directory. 191 192**Since**: 16 193 194**Parameters** 195 196| Name | Description | 197| ----------- | ------------------------------------------------------------ | 198| buffer | Pointer to the buffer. The cache directory string is written to this area. | 199| bufferSize | Buffer size. | 200| writeLength | Pointer to the length of the string written to the buffer when **ABILITY_RUNTIME_ERROR_CODE_NO_ERROR** is returned.| 201 202**Returns** 203 204Returns **ABILITY_RUNTIME_ERROR_CODE_NO_ERROR** if the operation is successful. 205 206Returns **ABILITY_RUNTIME_ERROR_CODE_PARAM_INVALID** if the passed-in value of **buffer** or **writeLength** is null or the buffer size is less than the size of the string to be written. 207 208Returns **ABILITY_RUNTIME_ERROR_CODE_CONTEXT_NOT_EXIST** if the context of the current environment does not exist. For example, the application-level context does not exist in the [child process](c-apis-ability-childprocess.md) created by the application. 209 210### OH_AbilityRuntime_ApplicationContextGetFilesDir 211 212``` 213AbilityRuntime_ErrorCode OH_AbilityRuntime_ApplicationContextGetFilesDir(char* buffer, const int32_t bufferSize, int32_t* writeLength) 214``` 215 216**Description** 217 218Obtains the application-level common file directory. 219 220**Since**: 16 221 222**Parameters** 223 224| Name | Description | 225| ----------- | ------------------------------------------------------------ | 226| buffer | Pointer to the buffer. The cache directory string is written to this area. | 227| bufferSize | Buffer size. | 228| writeLength | Pointer to the length of the string written to the buffer when **ABILITY_RUNTIME_ERROR_CODE_NO_ERROR** is returned.| 229 230**Returns** 231 232Returns **ABILITY_RUNTIME_ERROR_CODE_NO_ERROR** if the operation is successful. 233 234Returns **ABILITY_RUNTIME_ERROR_CODE_PARAM_INVALID** if the passed-in value of **buffer** or **writeLength** is null or the buffer size is less than the size of the string to be written. 235 236Returns **ABILITY_RUNTIME_ERROR_CODE_CONTEXT_NOT_EXIST** if the context of the current environment does not exist. For example, the application-level context does not exist in the [child process](c-apis-ability-childprocess.md) created by the application. 237 238### OH_AbilityRuntime_ApplicationContextGetDatabaseDir 239 240``` 241AbilityRuntime_ErrorCode OH_AbilityRuntime_ApplicationContextGetDatabaseDir(char* buffer, const int32_t bufferSize, int32_t* writeLength); 242``` 243 244**Description** 245 246Obtains the application-level database file directory. 247 248**Since**: 16 249 250**Parameters** 251 252| Name | Description | 253| ----------- | ------------------------------------------------------------ | 254| buffer | Pointer to the buffer. The cache directory string is written to this area. | 255| bufferSize | Buffer size. | 256| writeLength | Pointer to the length of the string written to the buffer when **ABILITY_RUNTIME_ERROR_CODE_NO_ERROR** is returned.| 257 258**Returns** 259 260Returns **ABILITY_RUNTIME_ERROR_CODE_NO_ERROR** if the operation is successful. 261 262Returns **ABILITY_RUNTIME_ERROR_CODE_PARAM_INVALID** if the passed-in value of **buffer** or **writeLength** is null or the buffer size is less than the size of the string to be written. 263 264Returns **ABILITY_RUNTIME_ERROR_CODE_CONTEXT_NOT_EXIST** if the context of the current environment does not exist. For example, the application-level context does not exist in the [child process](c-apis-ability-childprocess.md) created by the application. 265 266### OH_AbilityRuntime_ApplicationContextGetPreferencesDir 267 268``` 269AbilityRuntime_ErrorCode OH_AbilityRuntime_ApplicationContextGetPreferencesDir(char* buffer, const int32_t bufferSize, int32_t* writeLength) 270``` 271 272**Description** 273 274Obtains the application-level preferences file directory. 275 276**Since**: 16 277 278**Parameters** 279 280| Name | Description | 281| ----------- | ------------------------------------------------------------ | 282| buffer | Pointer to the buffer. The cache directory string is written to this area. | 283| bufferSize | Buffer size. | 284| writeLength | Pointer to the length of the string written to the buffer when **ABILITY_RUNTIME_ERROR_CODE_NO_ERROR** is returned.| 285 286**Returns** 287 288Returns **ABILITY_RUNTIME_ERROR_CODE_NO_ERROR** if the operation is successful. 289 290Returns **ABILITY_RUNTIME_ERROR_CODE_PARAM_INVALID** if the passed-in value of **buffer** or **writeLength** is null or the buffer size is less than the size of the string to be written. 291 292Returns **ABILITY_RUNTIME_ERROR_CODE_CONTEXT_NOT_EXIST** if the context of the current environment does not exist. For example, the application-level context does not exist in the [child process](c-apis-ability-childprocess.md) created by the application. 293 294### OH_AbilityRuntime_ApplicationContextGetBundleCodeDir 295 296``` 297AbilityRuntime_ErrorCode OH_AbilityRuntime_ApplicationContextGetBundleCodeDir(char* buffer, const int32_t bufferSize, int32_t* writeLength) 298``` 299 300**Description** 301 302Obtains the application-level installation file directory. 303 304**Since**: 16 305 306**Parameters** 307 308| Name | Description | 309| ----------- | ------------------------------------------------------------ | 310| buffer | Pointer to the buffer. The cache directory string is written to this area. | 311| bufferSize | Buffer size. | 312| writeLength | Pointer to the length of the string written to the buffer when **ABILITY_RUNTIME_ERROR_CODE_NO_ERROR** is returned.| 313 314**Returns** 315 316Returns **ABILITY_RUNTIME_ERROR_CODE_NO_ERROR** if the operation is successful. 317 318Returns **ABILITY_RUNTIME_ERROR_CODE_PARAM_INVALID** if the passed-in value of **buffer** or **writeLength** is null or the buffer size is less than the size of the string to be written. 319 320Returns **ABILITY_RUNTIME_ERROR_CODE_CONTEXT_NOT_EXIST** if the context of the current environment does not exist. For example, the application-level context does not exist in the [child process](c-apis-ability-childprocess.md) created by the application. 321 322### OH_AbilityRuntime_ApplicationContextGetDistributedFilesDir 323 324``` 325AbilityRuntime_ErrorCode OH_AbilityRuntime_ApplicationContextGetDistributedFilesDir(char* buffer, const int32_t bufferSize, int32_t* writeLength) 326``` 327 328**Description** 329 330Obtains the application-level distributed file directory. 331 332**Since**: 16 333 334**Parameters** 335 336| Name | Description | 337| ----------- | ------------------------------------------------------------ | 338| buffer | Pointer to the buffer. The cache directory string is written to this area. | 339| bufferSize | Buffer size. | 340| writeLength | Pointer to the length of the string written to the buffer when **ABILITY_RUNTIME_ERROR_CODE_NO_ERROR** is returned.| 341 342**Returns** 343 344Returns **ABILITY_RUNTIME_ERROR_CODE_NO_ERROR** if the operation is successful. 345 346Returns **ABILITY_RUNTIME_ERROR_CODE_PARAM_INVALID** if the passed-in value of **buffer** or **writeLength** is null or the buffer size is less than the size of the string to be written. 347 348Returns **ABILITY_RUNTIME_ERROR_CODE_CONTEXT_NOT_EXIST** if the context of the current environment does not exist. For example, the application-level context does not exist in the [child process](c-apis-ability-childprocess.md) created by the application. 349 350### OH_AbilityRuntime_ApplicationContextGetCloudFileDir 351 352``` 353AbilityRuntime_ErrorCode OH_AbilityRuntime_ApplicationContextGetCloudFileDir(char* buffer, const int32_t bufferSize, int32_t* writeLength) 354``` 355 356**Description** 357 358Obtains the application-level cloud file directory. 359 360**Since**: 16 361 362**Parameters** 363 364| Name | Description | 365| ----------- | ------------------------------------------------------------ | 366| buffer | Pointer to the buffer. The cache directory string is written to this area. | 367| bufferSize | Buffer size. | 368| writeLength | Pointer to the length of the string written to the buffer when **ABILITY_RUNTIME_ERROR_CODE_NO_ERROR** is returned.| 369 370**Returns** 371 372Returns **ABILITY_RUNTIME_ERROR_CODE_NO_ERROR** if the operation is successful. 373 374Returns **ABILITY_RUNTIME_ERROR_CODE_PARAM_INVALID** if the passed-in value of **buffer** or **writeLength** is null or the buffer size is less than the size of the string to be written. 375 376Returns **ABILITY_RUNTIME_ERROR_CODE_CONTEXT_NOT_EXIST** if the context of the current environment does not exist. For example, the application-level context does not exist in the [child process](c-apis-ability-childprocess.md) created by the application. 377 378### OH_AbilityRuntime_StartSelfUIAbility 379 380``` 381AbilityRuntime_ErrorCode OH_AbilityRuntime_StartSelfUIAbility(AbilityBase_Want *want) 382``` 383 384**Description** 385 386Starts the UIAbility of the current application. 387 388> **NOTE** 389> 390> This function is valid only for 2-in-1 devices. 391 392**Required permissions**: ohos.permission.NDK_START_SELF_UI_ABILITY 393 394**Since**: 15 395 396**Parameters** 397 398| Name | Description | 399| ----------- | ------------------------------------------------------------ | 400| want | Pointer to the Want information required for starting the UIAbility. | 401 402**Returns** 403 404Returns **ABILITY_RUNTIME_ERROR_CODE_NO_ERROR** if the API call is successful. 405 406Returns **ABILITY_RUNTIME_ERROR_CODE_PERMISSION_DENIED** if permission verification failed. 407 408Returns **ABILITY_RUNTIME_ERROR_CODE_PARAM_INVALID** if the Want information is empty, or if the bundleName or abilityName in the Want information is empty. 409 410Returns **ABILITY_RUNTIME_ERROR_CODE_NOT_SUPPORTED** if the device type is not supported. 411 412Returns **ABILITY_RUNTIME_ERROR_CODE_NO_SUCH_ABILITY** if the specified ability name does not exist. 413 414Returns **ABILITY_RUNTIME_ERROR_CODE_INCORRECT_ABILITY_TYPE** if the ability type is incorrect. 415 416Returns **ABILITY_RUNTIME_ERROR_CODE_CROWDTEST_EXPIRED** if the crowdtesting application expires. 417 418Returns **ABILITY_RUNTIME_ERROR_CODE_WUKONG_MODE** if the ability is started or stopped in Wukong mode. 419 420Returns **ABILITY_RUNTIME_ERROR_CODE_CONTROLLED** if the application is under control. 421 422Returns **ABILITY_RUNTIME_ERROR_CODE_EDM_CONTROLLED** if the application is under control by EDM. 423 424Returns **ABILITY_RUNTIME_ERROR_CODE_CROSS_APP** for an attempt to redirection to third-party applications in API versions later than 11. 425 426Returns **ABILITY_RUNTIME_ERROR_CODE_INTERNAL** if an internal error occurs. 427 428Returns **ABILITY_RUNTIME_ERROR_CODE_NOT_TOP_ABILITY** if the application is not a top one. 429 430**Example** 431```cpp 432#include <AbilityKit/ability_base/want.h> 433#include <AbilityKit/ability_runtime/application_context.h> 434 435void startSelfUIAbilityTest() 436{ 437 AbilityBase_Element element; 438 element.abilityName = const_cast<char*>("EntryAbility"); 439 element.bundleName = const_cast<char*>("com.exampl.myapplication"); 440 element.moduleName = const_cast<char*>("entry"); 441 AbilityBase_Want* want = OH_AbilityBase_CreateWant(element); 442 443 AbilityRuntime_ErrorCode err = OH_AbilityRuntime_StartSelfUIAbility(want); 444 if (err != ABILITY_RUNTIME_ERROR_CODE_NO_ERROR) { 445 // Record error logs and other service processing. 446 return; 447 } 448 // Destroy the Want to prevent memory leakage. 449 OH_AbilityBase_DestroyWant(want); 450} 451``` 452