Android in Activitymanager Learning notes (3)

Source: Internet
Author: User

Wrote 2 articles about Activitymanager, as shown below. are through the actual combat to understand the information inside, now feel too cumbersome, so do an API introduction more detailed. Just as you learned telephony before, it is useful to understand the whole activitymanager as a whole.


Android in Activitymanager Learning Notes (1)-memoryinfo

Android in Activitymanager Learning Notes (2)-runningserviceinfo


Activitymanager


The Android.app package contains 6 internal classes:

    • Memoryinfo
    • Processerrorstateinfo
    • Recenttaskinfo
    • Runningappprocessinfo
    • Runningserviceinfo
    • Runningtaskinfo


Start with the Activitymanager API.


Constants


Meta_home_alternate

<meta-data> tag values in the main activity

Move_task_no_user_action

Current activity does not receive a prompt for user-instigated activities

Move_task_with_home

Move the subsequent task immediately to the front

Recent_ignore_unavailable

Provides a list that does not contain any current tasks that are not visible to the user

recent_with_excluded

Return to All Tasks


Methods


Public BooleanClearapplicationuserdata()


Clear User Data


Public voiddumppackagestate(FileDescriptor fd, String packagename)

Get the various status information for the APK corresponding to the package name


Public ConfigurationinfoGetdeviceconfigurationinfo ()


Get Device configuration information


public intGetlargememoryclass()


When an application runs in a large stack space, the value of each applied memory fragment in the current device is estimated


public intgetlauncherlargeicondensity()


Lancher icon pixel density of the launcher


public intgetlauncherlargeiconsize()


Launcher icon Size


public intgetlauncherlargeiconsize()


The memory classification for each application of the current device is the bottom line of memory. Applications that fall below this value will crash.


Public voidGetmemoryinfo(Activitymanager.memoryinfo outinfo)


Memory information for the current system


Public static voidgetmymemorystate(Activitymanager.runningappprocessinfo outstate)


Returns the global memory state information for the caller process.


Public memoryinfo[]Getprocessmemoryinfo(int[] PIDs)


Memory information used by the process


Public list<activitymanager.processerrorstateinfo>getprocessesinerrorstate ()


Gets information about some processes that are currently running when the system has an error


Public list<activitymanager.recenttaskinfo>Getrecenttasks (int maxnum, int flags)


User-initiated Task list


Public list<activitymanager.runningappprocessinfo>getrunningappprocesses ()


Application process information currently running on the device


Public pendingintentGetrunningservicecontrolpanel(componentname service)


Returns a pendingintent that pendingintent launches a control panel that displays a list of services that are currently running on the system.


Public list<activitymanager.runningserviceinfo>getrunningservices (int maxnum)


Service information that is currently running


Public list<activitymanager.runningtaskinfo>Getrunningtasks (int maxnum)


Task information for the current system run


Public BooleanIslowramdevice()


Whether it is a low-memory device


Public Static Booleanisrunningintestharness()


Determine if the device is running in a test frame


Public Static BooleanIsuseramonkey()


Determine if the current device is monkey in a random order


Public voidkillbackgroundprocesses(String packagename)


Kill the background process of the corresponding package


Public voidMovetasktofront(int taskId, int flags, Bundle options)

Public voidMovetasktofront(int taskId, int flags)

The task that corresponds to the given ID is moved to the front of the task stack queue.


Public voidRestartpackage(String packagename)


Abolished in API 8


Nested class


Memoryinfo


The object is obtained through Getmemoryinfo (Activitymanager.memoryinfo), which can be used to retrieve valid memory information


Fields
Public long Availmem


Visible memory in the system


public Boolean Lowmemory


The system determines if it is in a low memory condition


Public long threshold


When memory is too low to start killing background services and other non-foreign processes, the critical value of the memory


Public long Totalmem


The number of all memory in the kernel


Processerrorstateinfo


Retrieving information in memory when an error occurs


Constans:


int CRASHED: Ben collapse

int not_responding: No response

int no_error:0. Status code, no error


Fields


public int Condition: status code in Process

Public byte[] Crashdata: (deprecated), null

Public String longmsg: a long message stating the state of the error

Pubic int PID: Process ID

Pubic String ProcessName: The process name of the process in which the error occurred or is crashing

Public String shortmsg: abbreviation for error code

Public String stackTrace: Stack trace information when an error occurs

Public String Tag: The activity name associated with the error

public int UID: User ID


Recenttaskinfo


Task information that the user recently accessed and started


Fields


Public Intent baseintent: Starts the original Intent of the task, which you can use to restart the task or move the current task to the front of the task list

Public charsequence Description: Describes the last state of a task

public int ID: uniquely identifies the currently running task

Public ComponentName Origactivity:intent-initiated entity controls

public int Persistentid: The permanent ID number of the task, whether or not the task is running


Runningappprocess


Information about a running process can be obtained through this class.


Constants


One of the values of the importance_background:importance variable. Processes that are in the background but still consume resources

One of the values of the importance_empt:importance variable. Empty process

One of the values of the importance_foreground:importance variable. The process that is in the user interface.

Importance_perceptible: Ibid. Still running something useful to the user

Importance_service: Ibid. The process contains services that are still running

Importance_visible: Ibid. Run something visible to the user, but not immediately displayed on the UI interface,

One of the values of the Reason_provider_in_use:importancereasoncode variable. The app's content provider is called by other processes

Reason_service_in_use: Ibid.

Reason_unknown: Ibid. No special reason


Fields


public int importance: Importance level

public int Importancereasoncode: Important Reason code

Public componentname Importancereasoncomponent: The name of the component to use in the current process

public int importancereasonpid: Process ID of the process client other processes.

public int lasttrimlevel: level reported to the last memory of the process

public int LRU: the least recently used algorithm, which is to sort importance.

public int PID: Process ID

Public string[] PkgList: All package names loaded by the process

Public String ProcessName: The name of the process associated with the current object

public int UID: User ID


Runningserviceinfo


Special services running in the current system


Constants


Flag_foreground: Foreground process

Flag_persistent_process: Ongoing process

Flag_started: Started

Flag_system_process: Core System processes


Fields


Public long activesince: The time of the first boot

public int Clientcount: number of clients connected to the service

public int Clientlabel: Client label

Public String clientpackage: Client package Name

public int CrashCount: Number of crashes during service run

public int flags: Run flag

Public Boolean foreground: determine if it is on the front-end UI interface

Public long lastactivitytime: last active time

public int PID: Process ID

Public String Process: the name of the processes in which the service resides

Public long restarting: the time of the restart, if non-null, represents that the service is not currently running. Wait for a period of time to restart.

Public ComponentName Service: Serviced components

Public Boolean started: whether it has been started

public int UID: User ID


Runningtaskinfo


Specific task information that is currently running on the system, which does not imply a task with process activity, but simply identifies that the user has left the task but is not closed, but the current system may kill the process, support its state only, and then restart after the user returns.


Fields


Public componentname baseactivity: Activity that was first started in the task.

Public charsquence Description: Description of the current state of the task

public int ID: task ID

public int numactivities: Number of active activity in the current task

Public in numrunning: Number of activity running in the current task (no stop and continuous activity)

Public Bitmap thumbnail: Thumbnail of the current state

Public componentname topactivity: Activity at the top of the task history stack.



Summarize


This article, from Activitymanager, gradually explains the 6 internal classes that represent the process, app, service, and task information involved in the program's operation. Have a preliminary understanding of the content managed by Activitymanager.



















Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.