1# Ability Framework Development 2 3## Is a guide similar to the Data ability development in the FA model available for the stage model? 4 5Applicable to: OpenHarmony SDK 3.2.3.5, stage model of API version 9 6 7A guide is available for the **DataShareExtensionAbility** class, which provides APIs for sharing data with other applications and managing the data, in the stage model. 8 9Reference: [DataShare Development](../database/database-datashare-guidelines.md) 10 11## What should I do if the UI does not respond when an ability is started? 12 13Applicable to: OpenHarmony SDK 3.2.5.3, stage model of API version 9 14 151. If the ability is started using **startAbility**, check whether the **abilityName** field in **want** uses the bundle name as the prefix. If yes, delete the bundle name. 16 172. Make sure the ability's home page file configured by **onWindowStageCreate** in the **MainAbility.ts** file is defined in the **main_pages.json** file. 18 193. You are advised to use the SDK and OpenHarmony SDK versions released on the same day. 20 21Reference: [Release Testing Version](https://gitee.com/openharmony-sig/oh-inner-release-management/blob/master/Release-Testing-Version.md) 22 23## How do I set the UI of an ability to transparent? 24 25Applicable to: OpenHarmony SDK 3.2.3.5, stage model of API version 9 26 27Set the background color of the top container component to transparent, and then set the **opacity** attribute of the XComponent to **0.01**. 28 29Example: 30 31``` 32build() { 33 Stack() { 34 XComponent({ 35 id: 'componentId', 36 type: 'surface', 37 }) 38 .width('100%') 39 .height('100%') 40 .opacity(0.01) 41 // Page content 42 } 43 .width('100%') 44 .height('100%') 45 .backgroundColor('rgba(255,255,255, 0)') 46} 47``` 48 49## How do I prevent "this" in a method from changing to "undefined" when the method is called? 50 51Applicable to: OpenHarmony SDK 3.2.5.3, stage model of API version 9 52 53Method 1: Add **.bind(this)** when calling the method. 54 55Method 2: Use the arrow function. 56 57## What should I do when the message "must have required property 'startWindowIcon'" is displayed? 58 59Applicable to: OpenHarmony SDK 3.2.3.5, stage model of API version 9 60 61Configure the **startWindowIcon** attribute under **abilities** in the **module.json5** file. 62 63Reference: [Application Package Structure (Stage Model)](../quick-start/module-configuration-file.md) 64 65Example: 66 67``` 68{ 69 "module": { 70 // Do something. 71 "abilities": [{ 72 // Do something. 73 "startWindowIcon": "$media:space", 74 "startWindowBackground": "$color:white", 75 }] 76 } 77} 78``` 79 80## How do I obtain a notification when the device orientation changes? 81 82Applicable to: OpenHarmony SDK 3.2.3.5, stage model of API version 9 83 84Implement the **onConfigurationUpdated** callback in the **Ability** class. The callback is triggered when the system language, color mode, or display parameters (such as the orientation and density) change. 85 86## Can I obtain the context through globalThis in the stage model? 87 88Applicable to: OpenHarmony SDK 3.2.5.5, stage model of API version 9 89 90Do not use **globalThis** to obtain the context in the stage model. This is because all the processes of an application share a JS VM instance in the stage model. Multiple abilities can run on these processes and share the same global object. If **globalThis** is used, the context of different abilities of the same JS VM instance may be returned. 91 92Reference of the recommended operation: [Context (Stage Model)](../application-models/application-context-stage.md) 93 94## How do I obtain the HAP installation path of application B from application A? 95 96Applicable to: OpenHarmony SDK 3.0 or later, stage model of API version 9 97 98First, request the system permission. For details, see [Having Your App Automatically Signed](https://developer.harmonyos.com/en/docs/documentation/doc-guides/ohos-auto-configuring-signature-information-0000001271659465). Then, import the **bundle** module, and call **bundle.getApplicationInfo()** to obtain application information based on the bundle name. Finally, use **application.moduleSourceDirs** to obtain the application storage path. 99 100## How is data returned when startAbilityForResult is called? 101 102Applicable to: OpenHarmony SDK3.0, stage model of API version 9 103 104The callee uses **AbilityContext.terminateSelfWithResult** to destroy its ability and pass parameters to **startAbilityForResult**. For details, see [AbilityContext](../reference/apis/js-apis-ability-context.md#abilitycontextterminateselfwithresult). 105 106## Can the lifecycle callback of a released FA widget be triggered when the widget is displayed in the service center so that the user login information can be obtained without opening the FA application? 107 108Applicable to: OpenHarmony SDK 3.2.5.5, FA model of API version 8 109 110After a widget is added, the **oncreate()** lifecycle is triggered so that related user information (silent login) can be displayed even when the application is not started. However, users must manually add the widget after the application is installed. 111 112## How do I obtain the context? 113 114Applicable to: OpenHarmony SDK 3.2.7.5, stage model of API version 9 115 116You can use **this.context** to obtain the context in the **MainAbility.ts** file or call **getContext(this)** to obtain the context on the component page. 117 118## What should I do when undefined is displayed for the calling of **abilityAccessCtrl.grantUserGrantedPermission** during API version 8 syntax verification? 119 120Applicable to: OpenHarmony SDK 3.0, FA model of API version 8 121 122**abilityAccessCtrl.grantUserGrantedPermission** is a system API. It is not available in the public SDK, which is provided as default on DevEco Studio. To use system APIs, switch to the full SDK. For details, see [Guide to Switching to Full SDK](../quick-start/full-sdk-switch-guide.md). 123 124## Which of the following Extension abilities are available in the public SDK: ServiceExtensionAbility, FormExtensionAbility, and DataShareExtensionAbility? 125 126Applicable to: OpenHarmony SDK 3.2.5.6, stage model of API version 9 127 128Among the aforementioned Extension abilities, only **FormExtensionAbility** is available in the public SDK. **ServiceExtensionAbility** and **DataShareExtensionAbility** are system APIs and available only in the full SDK. 129 130Public SDK: intended for application developers and does not contain system APIs that require system permissions. 131 132Full SDK: intended for original equipment manufacturers (OEMs) and contains system APIs that require system permissions. 133 134## Why can't I play GIF images cyclically on the widget? 135 136Applicable to: OpenHarmony SDK 3.2.5.6, stage model of API version 9 137 138The system does not support the display of GIF images on the widget. 139 140## How do I implement service login by touching a widget? 141 142Applicable to: OpenHarmony SDK 3.2.5.5, stage model of API version 9 143 144You can start an ability upon the touch and implement service login in the ability. 145 146## How do I redirect to the application details page in Settings? 147 148Applicable to: OpenHarmony SDK 3.2.6.5 149 150Refer to the following code: 151 152``` 153this.context.startAbility( 154{ 155 action: "action.settings.app.info", 156 parameters: { "settingsParamBundleName": "your app bundlename" } 157}) 158``` 159 160## How do I listen for screen rotation events? 161 162Applicable to: OpenHarmony SDK 3.2.5.5, stage model of API version 9 163 164Refer to the following code: 165 166``` 167let listener = mediaquery.matchMediaSync('(orientation: landscape)') 168onPortrait(mediaQueryResult) { 169if (mediaQueryResult.matches) { 170// Do something here. 171 } else { 172// Do something here. 173 } 174} 175listener.on('change', onPortrait) 176``` 177 178## How do I control the shadow background size during checkbox selection? 179 180Applicable to: OpenHarmony SDK 3.2.5.5, stage model of API version 9 181 182Set the **padding** attribute of the **\<checkbox>** component to control the shadow size. 183 184## How do I set the widget background to transparent? 185 186Applicable to: OpenHarmony SDK 3.2.5.5 187 1881. Create the **widget/resources/styles/default.json** file in the root directory of the widget. 189 1902. Add the following code to the **default.json** file: 191 192``` 193{ 194 "style": { 195 "app_background": "#00000000" 196 } 197} 198``` 199 200## How do I pass parameters for FA widgets? 201 202Applicable to: OpenHarmony SDK 3.2.5.5 203 204Use **featureAbility.getWant()** and **featureAbility.getContext()** to send data through **router** in the JSON file and use **featureAbility** to receive data in the JS file. 205 206## How do I trigger router.disableAlertBeforeBackPage and router.enableAlertBeforeBackPage? 207 208Applicable to: OpenHarmony SDK 3.2.5.5 209 210The following conditions must be met: 211 2121. Before the redirection to the previous page, a confirm dialog box will be displayed. Note that **router.disableAlertBeforeBackPage** is used to disable the display of a confirm dialog box before returning to the previous page (default), and **router.enableAlertBeforeBackPage** is used to enable the display. 213 2142. The system return key is used. 215