Context, ElementsCallbackpublic class AbilityPackage extends AbilityContext implements ElementsCallback
SystemCapability.Aafwk#ABILITYCONTEXT_IGNORE_SECURITY, CONTEXT_INCLUDE_CODE, CONTEXT_RESOUCE_ONLY, CONTEXT_RESTRICTED, MODE_APPEND, MODE_PRIVATE| 构造器 | 说明 |
|---|---|
AbilityPackage() |
A constructor used to create a
AbilityPackage instance. |
| 限定符和类型 | 方法 | 说明 |
|---|---|---|
void |
dispatchAbilitySavedState(PacMap outState) |
Called when
Ability#onSaveAbilityState(PacMap) was called on an ability. |
void |
onConfigurationUpdated(Configuration configuration) |
Called when the system configuration of the device changes.
|
void |
onEnd() |
Called when the application exits.
|
void |
onInitialize() |
Called when your module is starting, before any abilities in the module are loaded.
|
void |
onMemoryLevel(int level) |
Called when the system has determined to trim the memory, for example, when the ability is running in the
background and there is no enough memory for running as many background processes as possible.
|
void |
registerCallbacks(AbilityLifecycleCallbacks abilityLifecycleCallbacks,
ElementsCallback elementsCallback) |
|
void |
unregisterCallbacks(AbilityLifecycleCallbacks abilityLifecycleCallbacks,
ElementsCallback elementsCallback) |
Unregisters
AbilityLifecycleCallbacks and ElementsCallback objects. |
attachBaseContext, canRequestPermission, compelVerifyCallerPermission, compelVerifyCallerUriPermission, compelVerifyPermission, compelVerifyPermission, compelVerifyUriPermission, compelVerifyUriPermission, compelVerifyUriPermission, connectAbility, createBundleContext, createParallelTaskDispatcher, createSerialTaskDispatcher, deleteFile, disconnectAbility, displayUnlockMissionMessage, getAbilityInfo, getAbilityManager, getAbilityPackageContext, getApplicationContext, getApplicationInfo, getAppType, getBundleCodePath, getBundleManager, getBundleName, getBundleResourcePath, getCacheDir, getCaller, getCallingAbility, getCallingBundle, getClassloader, getCodeCacheDir, getColor, getColorMode, getContext, getDatabaseDir, getDataDir, getDir, getDisplayOrientation, getDistributedDir, getElementName, getExternalCacheDir, getExternalCacheDirs, getExternalFilesDir, getExternalFilesDirs, getExternalMediaDirs, getFilesDir, getGlobalTaskDispatcher, getHapModuleInfo, getIntArray, getLastStoredDataWhenConfigChanged, getLocalClassName, getMainTaskDispatcher, getNoBackupFilesDir, getPattern, getPreferencesDir, getProcessInfo, getProcessName, getResourceManager, getResourceManager, getString, getString, getStringArray, getTheme, getThemeId, getUITaskDispatcher, init, isCredentialEncryptedStorage, isDeviceEncryptedStorage, isUpdatingConfigurations, lockMission, printDrawnCompleted, requestPermissionsFromUser, restart, setColorMode, setDisplayOrientation, setPattern, setShowOnLockScreen, setTheme, setTransitionAnimation, setWakeUpScreen, startAbilities, startAbility, startAbility, startAbility, stopAbility, switchToCredentialEncryptedStorageContext, switchToDeviceEncryptedStorageContext, terminateAbility, terminateAbility, terminateAbilityResult, unlockMission, verifyCallingOrSelfPermission, verifyCallingPermission, verifyPermission, verifySelfPermissionpublic AbilityPackage()
AbilityPackage instance.public void onInitialize()
public void onEnd()
public void onMemoryLevel(int level)
onMemoryLevel 在接口中 ElementsCallbacklevel - Indicates the memory trim level, which shows the current memory usage status.public void onConfigurationUpdated(Configuration configuration)
This callback method is used only if the configurationChange field has been configured in the
config.json file for the ability currently running in the foreground.
Otherwise, the system restarts the ability instead of calling this callback method.
onConfigurationUpdated 在接口中 ElementsCallbackconfiguration - Indicates the new Configuration object.public void registerCallbacks(AbilityLifecycleCallbacks abilityLifecycleCallbacks, ElementsCallback elementsCallback)
AbilityLifecycleCallbacks and ElementsCallback objects
with this AbilityPackage object.
Callbacks in AbilityLifecycleCallbacks will be triggered when the ability
lifecycle in the application changes.
Callbacks in ElementsCallback will be triggered when the system configuration
or memory status of the device changes.
abilityLifecycleCallbacks - Indicates the AbilityLifecycleCallbacks object to register.
This parameter can be null,indicating that no such callback will be registered.elementsCallback - Indicates the ElementsCallback object to register.
This parameter can be null,indicating that no such callback will be registered.public void unregisterCallbacks(AbilityLifecycleCallbacks abilityLifecycleCallbacks, ElementsCallback elementsCallback)
AbilityLifecycleCallbacks and ElementsCallback objects.abilityLifecycleCallbacks - Indicates the ElementsCallback object to unregister.
This parameter can be null,indicating that no such callback will be unregistered.elementsCallback - Indicates the ElementsCallback object to unregister.
This parameter can be null,indicating that no such callback will be unregistered.public void dispatchAbilitySavedState(PacMap outState)
Ability#onSaveAbilityState(PacMap) was called on an ability.outState - Indicates the PacMap object passed to
Ability#onSaveAbilityState(PacMap) for storing user data and states.
This parameter cannot be null.