1e41f4b71Sopenharmony_ci# Want 2e41f4b71Sopenharmony_ci 3e41f4b71Sopenharmony_ciWant is a carrier for information transfer between objects (application components). Want can be used as a parameter of [startAbility](js-apis-inner-application-uiAbilityContext.md#uiabilitycontextstartability) 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. 4e41f4b71Sopenharmony_ci 5e41f4b71Sopenharmony_ci> **NOTE** 6e41f4b71Sopenharmony_ci> 7e41f4b71Sopenharmony_ci> The APIs of this module are supported since API version 6 and deprecated since API version 9. You are advised to use [@ohos.app.ability.Want](js-apis-app-ability-want.md) instead. Newly added APIs will be marked with a superscript to indicate their earliest API version. 8e41f4b71Sopenharmony_ci 9e41f4b71Sopenharmony_ci## Modules to Import 10e41f4b71Sopenharmony_ci 11e41f4b71Sopenharmony_ci```ts 12e41f4b71Sopenharmony_ciimport Want from '@ohos.app.ability.Want'; 13e41f4b71Sopenharmony_ci``` 14e41f4b71Sopenharmony_ci 15e41f4b71Sopenharmony_ci## Attributes 16e41f4b71Sopenharmony_ci 17e41f4b71Sopenharmony_ci**System capability**: SystemCapability.Ability.AbilityBase 18e41f4b71Sopenharmony_ci 19e41f4b71Sopenharmony_ci| Name | Type | Mandatory| Description | 20e41f4b71Sopenharmony_ci| ----------- | -------------------- | ---- | ------------------------------------------------------------ | 21e41f4b71Sopenharmony_ci| deviceId | string | No | ID of the device running the ability. If this field is unspecified, the local device is used. | 22e41f4b71Sopenharmony_ci| bundleName | string | No | Bundle name.| 23e41f4b71Sopenharmony_ci| abilityName | string | No | Name of the ability. If both **bundleName** and **abilityName** are specified in a **Want** object, the **Want** object can match a specific ability. The value of **abilityName** must be unique in an application.| 24e41f4b71Sopenharmony_ci| uri | string | No | URI. If **uri** is specified in a **Want** object, the **Want** object will match the specified URI information, including **scheme**, **schemeSpecificPart**, **authority**, and **path**.| 25e41f4b71Sopenharmony_ci| type | string | No | MIME type, that is, the type of the file to open, for example, **'text/xml'** and **'image/*'**. For details about the MIME type definition, see https://www.iana.org/assignments/media-types/media-types.xhtml?utm_source=ld246.com. | 26e41f4b71Sopenharmony_ci| flags | number | No | How the **Want** object will be handled. By default, numbers are passed in. For details, see [flags](js-apis-ability-wantConstant.md#flags).| 27e41f4b71Sopenharmony_ci| action | string | No | Action to take, such as viewing and sharing application details. In implicit Want, you can define this field and use it together with **uri** or **parameters** to specify the operation to be performed on the data. For details, see [action](js-apis-ability-wantConstant.md#action). For details about the definition and matching rules of implicit Want, see [Matching Rules of Explicit Want and Implicit Want](../../application-models/explicit-implicit-want-mappings.md). | 28e41f4b71Sopenharmony_ci| parameters | { [key: string]: any } | No | Want parameters in the form of custom key-value (KV) pairs. By default, the following keys are carried:<br>- **ohos.aafwk.callerPid**: PID of the caller.<br>- **ohos.aafwk.param.callerToken**: token of the caller.<br>- **ohos.aafwk.param.callerUid**: UID in [bundleInfo](js-apis-bundleManager-bundleInfo.md#bundleinfo), that is, the application UID in the bundle information.<br>- **component.startup.newRules**: whether to enable the new control rule.<br>- **moduleName**: module name of the caller. No matter what this field is set to, the correct module name will be sent to the peer.<br>- **ohos.dlp.params.sandbox**: available only for DLP files. | 29e41f4b71Sopenharmony_ci| entities | Array\<string> | No | Additional category information (such as browser and video player) of the target ability. It is a supplement to **action** in implicit Want and is used to filter ability types. | 30e41f4b71Sopenharmony_ci 31e41f4b71Sopenharmony_ci**Example** 32e41f4b71Sopenharmony_ci 33e41f4b71Sopenharmony_ci- Basic usage (called in a UIAbility object, where context in the example is the context object of the UIAbility). 34e41f4b71Sopenharmony_ci 35e41f4b71Sopenharmony_ci ```ts 36e41f4b71Sopenharmony_ci import AbilityConstant from '@ohos.app.ability.AbilityConstant'; 37e41f4b71Sopenharmony_ci import UIAbility from '@ohos.app.ability.UIAbility'; 38e41f4b71Sopenharmony_ci import Want from '@ohos.app.ability.Want'; 39e41f4b71Sopenharmony_ci import { BusinessError } from '@ohos.base'; 40e41f4b71Sopenharmony_ci 41e41f4b71Sopenharmony_ci let want: Want = { 42e41f4b71Sopenharmony_ci deviceId: '', // An empty deviceId indicates the local device. 43e41f4b71Sopenharmony_ci bundleName: 'com.example.myapplication', 44e41f4b71Sopenharmony_ci abilityName: 'EntryAbility', 45e41f4b71Sopenharmony_ci moduleName: 'entry', // moduleName is optional. 46e41f4b71Sopenharmony_ci }; 47e41f4b71Sopenharmony_ci class MyAbility extends UIAbility{ 48e41f4b71Sopenharmony_ci onCreate(want: Want, launchParam: AbilityConstant.LaunchParam){ 49e41f4b71Sopenharmony_ci this.context.startAbility(want, (error: BusinessError) => { 50e41f4b71Sopenharmony_ci // Start an ability explicitly. The bundleName, abilityName, and moduleName parameters work together to uniquely identify an ability. 51e41f4b71Sopenharmony_ci console.error(`error.code = ${error.code}`); 52e41f4b71Sopenharmony_ci }); 53e41f4b71Sopenharmony_ci } 54e41f4b71Sopenharmony_ci } 55e41f4b71Sopenharmony_ci ``` 56e41f4b71Sopenharmony_ci 57e41f4b71Sopenharmony_ci- Passing a file descriptor (FD) (called in a UIAbility object, where context in the example is the context object of the UIAbility): 58e41f4b71Sopenharmony_ci 59e41f4b71Sopenharmony_ci ```ts 60e41f4b71Sopenharmony_ci import fs from '@ohos.file.fs'; 61e41f4b71Sopenharmony_ci import Want from '@ohos.app.ability.Want'; 62e41f4b71Sopenharmony_ci import { BusinessError } from '@ohos.base'; 63e41f4b71Sopenharmony_ci import AbilityConstant from '@ohos.app.ability.AbilityConstant'; 64e41f4b71Sopenharmony_ci import UIAbility from '@ohos.app.ability.UIAbility'; 65e41f4b71Sopenharmony_ci 66e41f4b71Sopenharmony_ci // ... 67e41f4b71Sopenharmony_ci let fd: number = 0; 68e41f4b71Sopenharmony_ci try { 69e41f4b71Sopenharmony_ci fd = fs.openSync('/data/storage/el2/base/haps/pic.png').fd; 70e41f4b71Sopenharmony_ci } catch(e) { 71e41f4b71Sopenharmony_ci console.error(`openSync fail: ${JSON.stringify(e)}`); 72e41f4b71Sopenharmony_ci } 73e41f4b71Sopenharmony_ci 74e41f4b71Sopenharmony_ci 75e41f4b71Sopenharmony_ci let want: Want = { 76e41f4b71Sopenharmony_ci deviceId: '', // An empty deviceId indicates the local device. 77e41f4b71Sopenharmony_ci bundleName: 'com.example.myapplication', 78e41f4b71Sopenharmony_ci abilityName: 'EntryAbility', 79e41f4b71Sopenharmony_ci moduleName: 'entry', // moduleName is optional. 80e41f4b71Sopenharmony_ci parameters: { 81e41f4b71Sopenharmony_ci 'keyFd':{'type':'FD', 'value':fd} 82e41f4b71Sopenharmony_ci } 83e41f4b71Sopenharmony_ci }; 84e41f4b71Sopenharmony_ci class MyAbility extends UIAbility{ 85e41f4b71Sopenharmony_ci onCreate(want: Want, launchParam: AbilityConstant.LaunchParam){ 86e41f4b71Sopenharmony_ci this.context.startAbility(want, (error: BusinessError) => { 87e41f4b71Sopenharmony_ci // Start an ability explicitly. The bundleName, abilityName, and moduleName parameters work together to uniquely identify an ability. 88e41f4b71Sopenharmony_ci console.error(`error.code = ${error.code}`); 89e41f4b71Sopenharmony_ci }); 90e41f4b71Sopenharmony_ci } 91e41f4b71Sopenharmony_ci } 92e41f4b71Sopenharmony_ci // ... 93e41f4b71Sopenharmony_ci ``` 94e41f4b71Sopenharmony_ci 95