Intelligent Assistant
Chat with our virtual assistant to get answers promptly.
We use essential cookies for the website to function, as well as analytics cookies for analyzing and creating statistics of the website performance. To agree to the use of analytics cookies, click "Accept All". You can manage your preferences at any time by clicking "Cookie Settings" on the footer. More Information.
HarmonyOS
After an application without a continuous task is switched to the background, it should release the corresponding resources to facilitate system hibernation.
The BACKGROUND type of the runningLock.create API has been deprecated. If this type is required, the lock must be released when the application runs in the background.
- import { runningLock } from '@kit.BasicServicesKit';
- import { hilog } from '@kit.PerformanceAnalysisKit';
- import { BusinessError } from '@kit.BasicServicesKit';
-
- // Return to the background to release the lock
- runningLock.create('running_lock_test', runningLock.RunningLockType.BACKGROUND)
- .then((lock: runningLock.RunningLock) => {
- try {
- lock.unhold();
- } catch (error) {
- let err = error as BusinessError;
- hilog.warn(0x000, 'testTag', `setColorMode failed, code=${err.code}, message=${err.message}`);
- }
- })
- .catch((err: Error) => {
- console.error('create running lock failed, err: ' + err);
- });
For details about how to use the APIs related to RunningLock development, see RunningLock.
When audio resources are used, the system locks the audio resources for the application. If the audio resources are not released, the lock stays held. Therefore, the application should release the audio resources proactively in the background.
For details, see Proper Use of Audio Resources.
- import { UIAbility } from '@kit.AbilityKit';
- import { audio } from '@kit.AudioKit';
- import { BusinessError } from '@kit.BasicServicesKit';
- // ...
- export default class EntryAbility extends UIAbility {
- // ...
-
- onForeground(): void {
- //Apply for the resources required by the system, or reapply for the resources released in onBackground ()
- audio.createAudioRenderer(audioRendererOptions,(err: BusinessError) => {});
- }
-
- onBackground(): void {
- //Release resources when the UI is invisible
- audioRenderer.stop((err: BusinessError) => {});
- }
- }
Intelligent Assistant
Chat with our virtual assistant to get answers promptly.
Quick start
Helps you find desired resources with ease.