ILifecycle, Contextpublic abstract class IntentAbility extends Ability
This class is a child class of Ability.
You do not need to handle thread management-related works once this class is
used.
You should override the onProcessIntent(ohos.aafwk.content.Intent) method and use it
to handle required tasks. This method will be executed in a worker thread.
If there are multiple tasks, the system executes only one task at a time
in the order of task arrival time. After all tasks are complete, the
IntentAbility object automatically stops, and * you do not need to
call Ability#stopAbility(Intent intent) to stop it.
SystemCapability.Aafwk#ABILITYAbility.LayoutParamsHelper, Ability.WindowAttributeHelperFORM_INVISIBLE, FORM_VISIBLECONTEXT_IGNORE_SECURITY, CONTEXT_INCLUDE_CODE, CONTEXT_RESOUCE_ONLY, CONTEXT_RESTRICTED, MODE_APPEND, MODE_PRIVATE| 构造器 | 说明 |
|---|---|
IntentAbility(String name) |
A constructor used to create an
IntentAbility instance. |
| 限定符和类型 | 方法 | 说明 |
|---|---|---|
protected void |
onCommand(Intent intent,
boolean restart) |
已过时。
|
protected void |
onCommand(Intent intent,
boolean restart,
int startId) |
Called back when a Service ability is started.
|
protected abstract void |
onProcessIntent(Intent intent) |
Called for handling tasks every time the ability starts and
onCommand(ohos.aafwk.content.Intent,boolean)
is called. |
protected void |
onStart(Intent intent) |
Called when the ability is starting, and only be called once through its whole lifecycle.
|
addActionRoute, batchInsert, call, cancelBackgroundRunning, connectAbility, continueAbility, continueAbility, continueAbilityReversibly, continueAbilityReversibly, createPipeFile, delete, denormalizeUri, disconnectAbility, dispatchAccessibilityEventInfo, executeBatch, executeOperation, findComponentById, getAbilityName, getAbilityPackage, getAdmissionTransitionConcurEnabled, getAdmissionTransitionObject, getAVController, getBackTransitionConcurEnabled, getBackTransitionObject, getContinuationRegisterManager, getContinuationState, getCurrentFocus, getFileTypes, getIntent, getLayoutParams, getLifecycle, getOriginalDeviceId, getQuitTransitionObject, getReadmissionTransitionObject, getSharedItemAdmissionTransitionObject, getSharedItemBackTransitionObject, getSharedItemQuitTransitionObject, getSharedItemReadmissionTransitionObject, getState, getType, getVolumeTypeAdjustedByKey, getWindow, hasWindowFocus, insert, isTemporary, isTerminating, keepBackgroundRunning, normalizeUri, onAbilityResult, onAcquireFormState, onActive, onBackground, onBackPressed, onCastTempForm, onConfigurationUpdated, onConnect, onCreateForm, onCreateForm, onDeleteForm, onDeleteForm, onDisconnect, onEventDispatch, onEventNotify, onForeground, onHotkeyTriggered, onInactive, onInitialized, onKeyDown, onKeyPressAndHold, onKeyUp, onLeaveForeground, onMemoryLevel, onMissionDeleted, onNewDescription, onNewIntent, onOrientationChanged, onPostActive, onPostStart, onReconnect, onRequestPermissionsFromUserResult, onRestoreAbilityState, onSaveAbilityState, onSetCaller, onStop, onStoreDataWhenConfigChange, onTopActiveAbilityChanged, onTouchEvent, onTriggerFormEvent, onTriggerFormEvent, onUnloadForm, onUpdateForm, onUpdateForm, onWindowFocusChanged, openFile, openRawFile, parsePredictionArgsReference, parseValuesBucketReference, postTask, query, reload, reverseContinueAbility, setAbilitySliceAnimator, setAdmissionTransitionConcurEnabled, setAdmissionTransitionObject, setAVController, setBackTransitionConcurEnabled, setBackTransitionObject, setFormNextRefreshTime, setIntent, setIsAmbientMode, setLayoutParams, setMainRoute, setQuitTransitionObject, setReadmissionTransitionObject, setResult, setSharedItemAdmissionTransitionObject, setSharedItemBackTransitionObject, setSharedItemQuitTransitionObject, setSharedItemReadmissionTransitionObject, setSwipeToDismiss, setUIContent, setUIContent, setVolumeTypeAdjustedByKey, setWindowBackgroundColor, shutdown, startAbility, startAbility, startAbility, startAbility, startAbilityForResult, startAbilityForResult, startAssistAbility, stopAbility, stopAssistAbility, supportHighPerformanceUI, terminateAbility, update, updateForm, updateForm, updateForm, updateFormattachBaseContext, canRequestPermission, compelVerifyCallerPermission, compelVerifyCallerUriPermission, compelVerifyPermission, compelVerifyPermission, compelVerifyUriPermission, compelVerifyUriPermission, compelVerifyUriPermission, createBundleContext, createParallelTaskDispatcher, createSerialTaskDispatcher, deleteFile, 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, switchToCredentialEncryptedStorageContext, switchToDeviceEncryptedStorageContext, terminateAbility, terminateAbilityResult, unlockMission, verifyCallingOrSelfPermission, verifyCallingPermission, verifyPermission, verifySelfPermissionpublic IntentAbility(String name)
IntentAbility instance.name - Indicates the ability name, which is also used to identify a worker thread.protected void onStart(Intent intent)
You do not need to override this method for your child class. If you have to, override it by
calling the method in the IntentAbility base class.
onStart 在类中 Abilityintent - Indicates information carried when this ability is started. Note: For a Service ability,
null is passed.Ability.onStart(Intent)@Deprecated protected void onCommand(Intent intent, boolean restart)
You do not need to override this method for your child class. If you have to, override it
by calling the method in the IntentAbility base class.
onCommand 在类中 Abilityintent - Indicates the intent of the Service ability to start.restart - Indicates the startup mode. The value true indicates that the Service ability is restarted
after being destroyed, and the value false indicates a normal startup.Ability.onCommand(Intent, boolean)protected void onCommand(Intent intent, boolean restart, int startId)
You do not need to override this method for your child class. If you have to, override it
by calling the method in the IntentAbility base class.
onCommand 在类中 Abilityintent - Indicates the intent of Service to start.restart - Indicates the startup mode. The value true indicates that Service is restarted after being
destroyed, and the value false indicates a normal startup.startId - Indicates the number of times the Service ability has been started. The startId is
incremented by 1 every time the ability is started. For example, if the ability has been started
for six times, the value of startId is 6.Ability.onCommand(Intent, boolean, int)protected abstract void onProcessIntent(Intent intent)
onCommand(ohos.aafwk.content.Intent,boolean)
is called.
You should override this method for your IntentAbility child class. This method will
be executed in a separate worker thread instead of the main thread to prevent time-consuming
tasks from affecting the application responsiveness.
intent - Indicates the Intent object containing the task information.