LiveViewLockScreenExtensionAbility is the ExtensionAbility component for the visual area of the immersive lock screen live view. It inherits from UIExtensionAbility, and is designed for real-time activity scenarios that require displaying rich content on the lock screen. By inheriting from this class and implementing your app's extension components, you can visually present more data and provide more quick actions directly on the lock screen without requiring the user to unlock the device.
Since: 5.0.0(12)
LiveViewLockScreenExtensionAbility runs in an independent subprocess and cannot start other abilities across processes.
To ensure system security and stability and prevent LiveViewLockScreenExtensionAbility from abusing system resources, the system restricts its capabilities. Referencing certain modules is not supported. For details, please refer to the Appendix.
import { LiveViewLockScreenExtensionAbility } from '@kit.LiveViewKit'; Device behavior differences: This module is supported on phones and tablets, but does not work on other devices.
Lock screen immersive live view extension ability, which inherits from UIExtensionAbility.
Model restriction: The attributes can be used only in the stage model.
System capability: SystemCapability.LiveView.LiveViewService
Device behavior differences: This API is supported on phones and tablets, but does not work on other devices.
Since: 5.0.0(12)
| Name | Type | Read-Only | Optional | Description |
|---|---|---|---|---|
| context | LiveViewLockScreenExtensionContext | No | No | Context of LiveViewLockScreenExtensionAbility, which inherits from ExtensionContext. |
import { LiveViewLockScreenExtensionAbility } from '@kit.LiveViewKit';
import { UIExtensionContentSession, Want } from '@kit.AbilityKit';
import { hilog } from '@kit.PerformanceAnalysisKit';
export default class LiveViewLockScreenExtAbility extends LiveViewLockScreenExtensionAbility {
onCreate(): void {
hilog.info(0x0000, 'LiveViewLockScreenTag', 'LiveViewLockScreenExtAbility onCreate begin.');
}
onSessionCreate(want: Want, session: UIExtensionContentSession): void {
hilog.info(0x0000, 'LiveViewLockScreenTag', 'LiveViewLockScreenExtAbility onSessionCreate begin.');
let param: Record<string, UIExtensionContentSession> = {
'session': session
};
let storage: LocalStorage = new LocalStorage(param);
// Parse parameters passed in liveViewLocalScreenAbilityParameters.
const parameters = want?.parameters;
let words: string = parameters?.['words'] ? parameters?.['words'] as string : 'Hello World!';
storage.setOrCreate('words', words);
// Load the lock screen immersive live view page.
session.loadContent('pages/LiveViewLockScreenPage', storage);
}
} The following table lists the APIs that LiveViewLockScreenExtensionAbility is not allowed to call.