[HarmonyOS] [FAQ] Answers to questions related to HarmonyOS application development (2)

【Written in front】

I have shared with you some issues related to HarmonyOS application development before, and I will continue to share with you today!

 

【Prerequisite Introduction】

This document mainly summarizes the answers to some questions that may be encountered during the development of HarmonyOS. It mainly focuses on HarmonyOS, including but not limited to different API versions of HarmonyOS development, UI components, DevEco Studio, Gitee sample code, etc. It will continue to be updated as the work progresses.

 

【FAQ】

1. On the HarmonyOS form page, when the page slides down and clicks on the input box to get the focus, the pop-up keyboard will cover the input box.
This problem has been solved in API 9, and other methods can be used to avoid it, such as: get the focus soft keyboard After popping up, the form position can be moved up.

 

2. LiteWearable lightweight smart wearable application, put in hundreds of K picture materials, the size of the generated package increases by tens of megabytes, and cannot be installed in the watch.
For the packaging method of lightweight smart wearable applications, the increase in picture materials leads to an increase in package size. At present, the package size can only be controlled by controlling the size of the picture, and there is no other way to avoid it.

 

3. DevEco overseas version and domestic version The
domestic DevEco version can be downloaded through this link:

https://developer.harmonyos.com/cn/develop/deveco-studio#download
Overseas DevEco version can be downloaded through this link:

https://developer.harmonyos.com/en/develop/deveco-studio#download
Overseas versions are slower to update than domestic versions. It is not recommended for overseas developers to use higher domestic versions because the SDK related to higher versions has not been pushed Overseas, some SDKs may not be downloaded.

 

4. Is it possible to set a single border in the ArkTS API 8 component border setting?
ArkTS language, API 8 does not support single border setting, API 9 starts to support, the reference document is as follows:
API8 border setting:

https://developer.harmonyos.com/cn/docs/documentation/doc-references/ts-universal-attributes-border-0000001333720989#ZH-CN_TOPIC_0000001333720989__ attribute
API9 border settings:

https://developer.harmonyos.com/en/docs/documentation/doc-references-V3/ts-universal-attributes-border-0000001478341105-V3?catalogVersion=V3#ZH-CN_TOPIC_0000001544375493__Attributes

 

5. API6 Java language, how to restart Ability?
You can restart the application Ability through the getContext().restart(); method. Note that this method needs to be called in the main thread. The example is as follows:

cke_11248.png

 

6. HarmonyOS about accessing application directories and non-application directories
Java language using File-related API, ArkTS or JS language @ohos.fileio modules can only access the application directory and
non-application directories Currently only provides media library management @ohos.multimedia .mediaLibrary, this module is only supported by ArkTS and JS, and Java has no related API to support access to non-application directories.
In addition, you can look at the DataAbility function, which supports file sharing between different applications.

 

7. When the HarmonyOS Refresh component uses the $$ operator for two-way binding, the editor reports an error "Cannot find name '$$this'" (API9). The
Refresh component in the editor uses $$ to report an error, which is a false report by the editor, and the operation is normal. Yes, you can temporarily ignore this error report, and this problem will be fixed in subsequent versions.
The editor reports an error as follows:

cke_16617.png

 

8. How does HarmonyOS create a mobile phone hotspot through code in MainAbilitySlice? (API6 Java) You
can refer to the following document to add a specified hotspot:
https://developer.harmonyos.com/cn/docs/documentation/doc-guides/connectivity-wlan -untrusted-hotspots-0000001063403862#section20770334143820
For other interface functions of WLAN, please refer to the following document for viewing:
https://developer.harmonyos.com/cn/docs/documentation/doc-guides/connectivity-wlan-overview-0000000000030016
WLAN related functions Demo sample code: https://gitee.com/harmonyos/samples/tree/master/network/WLAN

 

9. How does HarmonyOS convert the IP address obtained through getIpAddress() into an actual ip address, such as 192.168.xxx.xxx? (API6  Java)
can refer to the following method for conversion, ip is the address obtained through getIpAddress()
(ip & 0xFF) + "." + ((ip >> 8) & 0xFF) + "." + ((ip >> 16) & 0xFF) + "." + (ip >> 24 & 0xFF)

 

10. If HarmonyOS wants to keep the application in the background to obtain location information, can it only apply for the LOCATION_IN_BACKGROUND permission instead of the LOCATION permission?
No, you must apply for the LOCATION permission at the same time to apply for the LOCATION_IN_BACKGROUND permission. When applying for the two permissions together, a permission confirmation box will pop up, and the user can choose "Allow only during use" and "Always allow"; if you only apply for the LOCATION permission, only the popup will pop up The "Allow only during the trial period" selection box cannot pop up the selection box with only "Always allow".
Get the location permission reference document:

https://developer.harmonyos.com/cn/docs/documentation/doc-guides/security-permissions-available-0000001051089272#section1727613371109

cke_28335.png

 


Continuously updating...

 

 For more comprehensive technical articles, please visit https://developer.huawei.com/consumer/cn/forum/?ha_source=zzh

{{o.name}}
{{m.name}}

Guess you like

Origin my.oschina.net/u/4478396/blog/9105274