Delphi Android ActivityManager(提供了接口, 利用它可以方便的对Memory, Processes, Task, Service 等进行管)

ActivityManager:   对Activity交互提供了接口, 利用它可以方便的对Memory, Processes, Task, Service 等进行管理,. 这里对Delphi接口进行了翻译,详细信息可以访问官方网站。

[delphi] view plain copy
 
  1. { 
  2.   android.app.ActivityManager imported by flcop(zylove619@hotmail.com) 
  3. }  
  4.   
  5. unit Androidapi.JNI.ActivityManager;  
  6.   
  7. interface  
  8.   
  9. uses  
  10.   System.SysUtils,  
  11.   FMX.Helpers.Android,  
  12.   Androidapi.JNI.JavaTypes,  
  13.   Androidapi.JNIBridge,  
  14.   Androidapi.JNI.GraphicsContentViewText,  
  15.   Androidapi.JNI.Os,  
  16.   Androidapi.JNI.App;  
  17.   
  18. type  
  19.   
  20. { Class forward declarations }  
  21.   JDebug_MemoryInfo = interface;  
  22.   JActivityManager_MemoryInfo = interface;  
  23.   JActivityManager_ProcessErrorStateInfo = interface;  
  24.   JActivityManager_RecentTaskInfo = interface;  
  25.   JActivityManager_RunningAppProcessInfo = interface;  
  26.   JActivityManager_RunningServiceInfo = interface;  
  27.   JActivityManager_RunningTaskInfo = interface;  
  28.   JActivityManager = interface;  
  29.   
  30. { http://developer.android.com/reference/android/os/Debug.MemoryInfo.html 
  31.   Added in API level 1 }  
  32.   JDebug_MemoryInfoClass = interface(JObjectClass)  
  33.   ['{E7545CF8-CFF5-40EE-9082-380FA48C4464}']  
  34.     { Property Methods }  
  35.     function _GetCREATOR: JParcelable_Creator;  
  36.     { Methods }  
  37.     function init: JDebug_MemoryInfo; cdecl;  
  38.     { Properties }  
  39.     property CREATOR: JParcelable_Creator read _GetCREATOR;  
  40.   end;  
  41.   
  42.   [JavaSignature('android/os/Debug$MemoryInfo')]  
  43.   JDebug_MemoryInfo = interface(JObject)  
  44.   ['{577F2E29-A53C-4A3C-8548-21F6D6001EF6}']  
  45.     { Property Methods }  
  46.     function _GetdalvikPrivateDirty: Integer;  
  47.     procedure _SetdalvikPrivateDirty(Value: Integer);  
  48.     function _GetdalvikPss: Integer;  
  49.     procedure _SetdalvikPss(Value: Integer);  
  50.     function _GetdalvikSharedDirty: Integer;  
  51.     procedure _SetdalvikSharedDirty(Value: Integer);  
  52.     function _GetnativePrivateDirty: Integer;  
  53.     procedure _SetnativePrivateDirty(Value: Integer);  
  54.     function _GetnativePss: Integer;  
  55.     procedure _SetnativePss(Value: Integer);  
  56.     function _GetnativeSharedDirty: Integer;  
  57.     procedure _SetnativeSharedDirty(Value: Integer);  
  58.     function _GetotherPrivateDirty: Integer;  
  59.     procedure _SetotherPrivateDirty(Value: Integer);  
  60.     function _GetotherPss: Integer;  
  61.     procedure _SetotherPss(Value: Integer);  
  62.     function _GetotherSharedDirty: Integer;  
  63.     procedure _SetotherSharedDirty(Value: Integer);  
  64.     { Methods }  
  65.     // Added in API level 5  
  66.     function describeContents: Integer; cdecl;  
  67.     // Added in API level 5  
  68.     function getTotalPrivateDirty: Integer; cdecl;  
  69.     // Added in API level 5  
  70.     function getTotalPss: Integer; cdecl;  
  71.     // Added in API level 5  
  72.     function getTotalSharedDirty: Integer; cdecl;  
  73.     // Added in API level 5  
  74.     procedure readFromParcel(source: JParcel); cdecl;  
  75.     // Added in API level 5  
  76.     procedure writeToParcel(dest: JParcel; flags: Integer); cdecl;  
  77.     { Properties }  
  78.     property dalvikPrivateDirty: Integer read _GetdalvikPrivateDirty write _SetdalvikPrivateDirty;  
  79.     property dalvikPss: Integer read _GetdalvikPss write _SetdalvikPss;  
  80.     property dalvikSharedDirty: Integer read _GetdalvikSharedDirty write _SetdalvikSharedDirty;  
  81.     property nativePrivateDirty: Integer read _GetnativePrivateDirty write _SetnativePrivateDirty;  
  82.     property nativePss: Integer read _GetnativePss write _SetnativePss;  
  83.     property nativeSharedDirty: Integer read _GetnativeSharedDirty write _SetnativeSharedDirty;  
  84.     property otherPrivateDirty: Integer read _GetotherPrivateDirty write _SetotherPrivateDirty;  
  85.     property otherPss: Integer read _GetotherPss write _SetotherPss;  
  86.     property otherSharedDirty: Integer read _GetotherSharedDirty write _SetotherSharedDirty;  
  87.   end;  
  88.   TJDebug_MemoryInfo = class(TJavaGenericImport<JDebug_MemoryInfoClass,  
  89.     JDebug_MemoryInfo>) end;  
  90.   
  91. { http://developer.android.com/reference/android/app/ActivityManager.MemoryInfo.html 
  92.   Added in API level 1 }  
  93.   JActivityManager_MemoryInfoClass = interface(JObjectClass)  
  94.   ['{093B391C-56F6-47F9-96A5-CF4F4101F614}']  
  95.     { Property Methods }  
  96.     function _GetCREATOR: JParcelable_Creator;  
  97.     { Methods }  
  98.     function init: JActivityManager_MemoryInfo; cdecl;  
  99.     { Properties }  
  100.     property CREATOR: JParcelable_Creator read _GetCREATOR;  
  101.   end;  
  102.   
  103.   [JavaSignature('android/app/ActivityManager$MemoryInfo')]  
  104.   JActivityManager_MemoryInfo = interface(JObject)  
  105.   ['{B6B801F7-3E6F-4BF9-9952-8356A7026725}']  
  106.     { Property Methods }  
  107.     function _GetavailMem: Int64;  
  108.     function _GetlowMemory: Boolean;  
  109.     function _Getthreshold: Int64;  
  110.     function _GettotalMem: Int64;  
  111.     { Methods }  
  112.     function describeContents: Integer; cdecl;  
  113.     procedure readFromParcel(source: JParcel); cdecl;  
  114.     procedure writeToParcel(dest: JParcel; flags: Integer); cdecl;  
  115.     { Properties }  
  116.     property availMem: Int64 read _GetavailMem;  
  117.     property lowMemory: Boolean read _GetlowMemory;  
  118.     property threshold: Int64 read _Getthreshold;  
  119.     // Added in API level 16  
  120.     property totalMem: Int64 read _GettotalMem;  
  121.   end;  
  122.   TJActivityManager_MemoryInfo = class(TJavaGenericImport<JActivityManager_MemoryInfoClass,  
  123.     JActivityManager_MemoryInfo>) end;  
  124.   
  125. { http://developer.android.com/reference/android/app/ActivityManager.ProcessErrorStateInfo.html 
  126.   Added in API level 1 }  
  127.   JActivityManager_ProcessErrorStateInfoClass = interface(JObjectClass)  
  128.   ['{B2DDD02D-B205-4412-89B7-418BC28DA58D}']  
  129.     { Property Methods }  
  130.     function _GetCREATOR: JParcelable_Creator;  
  131.     function _GetCRASHED: Integer;  
  132.     function _GetNOT_RESPONDING: Integer;  
  133.     function _GetNO_ERROR: Integer;  
  134.     { Methods }  
  135.     function init: JActivityManager_ProcessErrorStateInfo; cdecl;  
  136.     { Properties }  
  137.     property CREATOR: JParcelable_Creator read _GetCREATOR;  
  138.     property CRASHED: Integer read _GetCRASHED;  
  139.     property NOT_RESPONDING: Integer read _GetNOT_RESPONDING;  
  140.     property NO_ERROR: Integer read _GetNO_ERROR;  
  141.   end;  
  142.   
  143.   [JavaSignature('android/app/ActivityManager$ProcessErrorStateInfo')]  
  144.   JActivityManager_ProcessErrorStateInfo = interface(JObject)  
  145.   ['{7406BE27-6395-44F4-8CC7-633375617A2A}']  
  146.     { Property Methods }  
  147.     function _Getcondition: Integer;  
  148.     procedure _Setcondition(Value: Integer);  
  149.     function _GetcrashData: TJavaArray<Byte>;  
  150.     procedure _SetcrashData(Value: TJavaArray<Byte>);  
  151.     function _GetlongMsg: JString;  
  152.     procedure _SetlongMsg(Value: JString);  
  153.     function _Getpid: Integer;  
  154.     procedure _Setpid(Value: Integer);  
  155.     function _GetprocessName: JString;  
  156.     procedure _SetprocessName(Value: JString);  
  157.     function _GetshortMsg: JString;  
  158.     procedure _SetshortMsg(Value: JString);  
  159.     function _GetstackTrace: JString;  
  160.     procedure _SetstackTrace(Value: JString);  
  161.     function _Gettag: JString;  
  162.     procedure _Settag(Value: JString);  
  163.     function _Getuid: Integer;  
  164.     procedure _Setuid(Value: Integer);  
  165.     { Methods }  
  166.     function describeContents: Integer; cdecl;  
  167.     procedure readFromParcel(source: JParcel); cdecl;  
  168.     procedure writeToParcel(dest: JParcel; flags: Integer); cdecl;  
  169.     { Properties }  
  170.     property condition: Integer read _Getcondition write _Setcondition;  
  171.     property crashData: TJavaArray<Byte> read _GetcrashData write _SetcrashData;  
  172.     property longMsg: JString read _GetlongMsg write _SetlongMsg;  
  173.     property pid: Integer read _Getpid write _Setpid;  
  174.     property processName: JString read _GetprocessName write _SetprocessName;  
  175.     property shortMsg: JString read _GetshortMsg write _SetshortMsg;  
  176.     // Added in API level 8  
  177.     property stackTrace: JString read _GetstackTrace write _SetstackTrace;  
  178.     property tag: JString read _Gettag write _Settag;  
  179.     property uid: Integer read _Getuid write _Setuid;  
  180.   end;  
  181.   TJActivityManager_ProcessErrorStateInfo = class(TJavaGenericImport<JActivityManager_ProcessErrorStateInfoClass,  
  182.     JActivityManager_ProcessErrorStateInfo>) end;  
  183.   
  184. { http://developer.android.com/reference/android/app/ActivityManager.RecentTaskInfo.html 
  185.   Added in API level 1 }  
  186.   JActivityManager_RecentTaskInfoClass = interface(JObjectClass)  
  187.   ['{4AE6025B-0BEA-4D81-8E3F-4EC6F7BA8EEF}']  
  188.     { Property Methods }  
  189.     function _GetCREATOR: JParcelable_Creator;  
  190.     { Methods }  
  191.     function init: JActivityManager_RecentTaskInfo; cdecl;  
  192.     { Properties }  
  193.     property CREATOR: JParcelable_Creator read _GetCREATOR;  
  194.   end;  
  195.   
  196.   [JavaSignature('android/app/ActivityManager$RecentTaskInfo')]  
  197.   JActivityManager_RecentTaskInfo = interface(JObject)  
  198.   ['{02A5EDBF-B7CC-4C63-BACD-0F1A195C6969}']  
  199.     { Property Methods }  
  200.     function _GetbaseIntent: JIntent;  
  201.     procedure _SetbaseIntent(Value: JIntent);  
  202.     function _Getdescription: JCharSequence;  
  203.     procedure _Setdescription(Value: JCharSequence);  
  204.     function _Getid: Integer;  
  205.     procedure _Setid(Value: Integer);  
  206.     function _GetorigActivity: JComponentName;  
  207.     procedure _SetorigActivity(Value: JComponentName);  
  208.     function _GetpersistentId: Integer;  
  209.     procedure _SetpersistentId(Value: Integer);  
  210.     { Methods }  
  211.     function describeContents: Integer; cdecl;  
  212.     procedure readFromParcel(source: JParcel); cdecl;  
  213.     procedure writeToParcel(dest: JParcel; flags: Integer); cdecl;  
  214.     { Properties }  
  215.     property baseIntent: JIntent read _GetbaseIntent write _SetbaseIntent;  
  216.     // Added in API level 11  
  217.     property description: JCharSequence read _Getdescription write _Setdescription;  
  218.     property id: Integer read _Getid write _Setid;  
  219.     property origActivity: JComponentName read _GetorigActivity write _SetorigActivity;  
  220.     // Added in API level 12  
  221.     property persistentId: Integer read _GetpersistentId write _SetpersistentId;  
  222.   end;  
  223.   TJActivityManager_RecentTaskInfo = class(TJavaGenericImport<JActivityManager_RecentTaskInfoClass,  
  224.     JActivityManager_RecentTaskInfo>) end;  
  225.   
  226. { http://developer.android.com/reference/android/app/ActivityManager.RunningAppProcessInfo.html 
  227.   Added in API level 3 }  
  228.   JActivityManager_RunningAppProcessInfoClass = interface(JObjectClass)  
  229.   ['{F24C0121-C062-4A2B-9363-E97A50E2FC41}']  
  230.     { Property Methods }  
  231.     function _GetCREATOR: JParcelable_Creator;  
  232.     function _GetIMPORTANCE_BACKGROUND: Integer;  
  233.     function _GetIMPORTANCE_EMPTY: Integer;  
  234.     function _GetIMPORTANCE_FOREGROUND: Integer;  
  235.     function _GetIMPORTANCE_PERCEPTIBLE: Integer;  
  236.     function _GetIMPORTANCE_SERVICE: Integer;  
  237.     function _GetIMPORTANCE_VISIBLE: Integer;  
  238.     function _GetREASON_PROVIDER_IN_USE: Integer;  
  239.     function _GetREASON_SERVICE_IN_USE: Integer;  
  240.     function _GetREASON_UNKNOWN: Integer;  
  241.     { Methods }  
  242.     function init: JActivityManager_RunningAppProcessInfo; cdecl; overload;  
  243.     function init(pProcessName: JString; pPid: Integer; pArr: TJavaObjectArray<JString>):  
  244.       JActivityManager_RunningAppProcessInfo; cdecl; overload;  
  245.     { Properties }  
  246.     property CREATOR: JParcelable_Creator read _GetCREATOR;  
  247.     property IMPORTANCE_BACKGROUND: Integer read _GetIMPORTANCE_BACKGROUND;  
  248.     property IMPORTANCE_EMPTY: Integer read _GetIMPORTANCE_EMPTY;  
  249.     property IMPORTANCE_FOREGROUND: Integer read _GetIMPORTANCE_FOREGROUND;  
  250.     // Added in API level 9  
  251.     property IMPORTANCE_PERCEPTIBLE: Integer read _GetIMPORTANCE_PERCEPTIBLE;  
  252.     property IMPORTANCE_SERVICE: Integer read _GetIMPORTANCE_SERVICE;  
  253.     property IMPORTANCE_VISIBLE: Integer read _GetIMPORTANCE_VISIBLE;  
  254.     // Added in API level 5  
  255.     property REASON_PROVIDER_IN_USE: Integer read _GetREASON_PROVIDER_IN_USE;  
  256.     // Added in API level 5  
  257.     property REASON_SERVICE_IN_USE: Integer read _GetREASON_SERVICE_IN_USE;  
  258.     // Added in API level 5  
  259.     property REASON_UNKNOWN: Integer read _GetREASON_UNKNOWN;  
  260.   end;  
  261.   
  262.   [JavaSignature('android/app/ActivityManager$RunningAppProcessInfo')]  
  263.   JActivityManager_RunningAppProcessInfo = interface(JObject)  
  264.   ['{3E72F05C-6CF2-4971-B34B-5FE4C414913D}']  
  265.     { Property Methods }  
  266.     function _Getimportance: Integer;  
  267.     procedure _Setimportance(Value: Integer);  
  268.     function _GetimportanceReasonCode: Integer;  
  269.     procedure _SetimportanceReasonCode(Value: Integer);  
  270.     function _GetimportanceReasonComponent: JComponentName;  
  271.     procedure _SetimportanceReasonComponent(Value: JComponentName);  
  272.     function _GetimportanceReasonPid: Integer;  
  273.     procedure _SetimportanceReasonPid(Value: Integer);  
  274.     function _GetlastTrimLevel: Integer;  
  275.     procedure _SetlastTrimLevel(Value: Integer);  
  276.     function _Getlru: Integer;  
  277.     procedure _Setlru(Value: Integer);  
  278.     function _Getpid: Integer;  
  279.     procedure _Setpid(Value: Integer);  
  280.     function _GetpkgList: TJavaObjectArray<JString>;  
  281.     procedure _SetpkgList(Value: TJavaObjectArray<JString>);  
  282.     function _GetprocessName: JString;  
  283.     procedure _SetprocessName(Value: JString);  
  284.     function _Getuid: Integer;  
  285.     procedure _Setuid(Value: Integer);  
  286.     { Methods }  
  287.     function describeContents: Integer; cdecl;  
  288.     procedure readFromParcel(source: JParcel); cdecl;  
  289.     procedure writeToParcel(dest: JParcel; flags: Integer); cdecl;  
  290.     { Properties }  
  291.     property importance: Integer read _Getimportance write _Setimportance;  
  292.     // Added in API level 5  
  293.     property importanceReasonCode: Integer read _GetimportanceReasonCode write _SetimportanceReasonCode;  
  294.     // Added in API level 5  
  295.     property importanceReasonComponent: JComponentName read _GetimportanceReasonComponent write _SetimportanceReasonComponent;  
  296.     // Added in API level 5  
  297.     property importanceReasonPid: Integer read _GetimportanceReasonPid write _SetimportanceReasonPid;  
  298.     // Added in API level 16  
  299.     property lastTrimLevel: Integer read _GetlastTrimLevel write _SetlastTrimLevel;  
  300.     property lru: Integer read _Getlru write _Setlru;  
  301.     property pid: Integer read _Getpid write _Setpid;  
  302.     property pkgList: TJavaObjectArray<JString> read _GetpkgList write _SetpkgList;  
  303.     property processName: JString read _GetprocessName write _SetprocessName;  
  304.     // Added in API level 5  
  305.     property uid: Integer read _Getuid write _Setuid;  
  306.   end;  
  307.   TJActivityManager_RunningAppProcessInfo = class(TJavaGenericImport<JActivityManager_RunningAppProcessInfoClass,  
  308.     JActivityManager_RunningAppProcessInfo>) end;  
  309.   
  310. { http://developer.android.com/reference/android/app/ActivityManager.RunningServiceInfo.html 
  311.   Added in API level 1 }  
  312.   JActivityManager_RunningServiceInfoClass = interface(JObjectClass)  
  313.   ['{8A01CD6D-5177-4F74-A65E-20BAC0B76F0F}']  
  314.     { Property Methods }  
  315.     function _GetCREATOR: JParcelable_Creator;  
  316.     function _GetFLAG_FOREGROUND: Integer;  
  317.     function _GetFLAG_PERSISTENT_PROCESS: Integer;  
  318.     function _GetFLAG_STARTED: Integer;  
  319.     function _GetFLAG_SYSTEM_PROCESS: Integer;  
  320.     { Methods }  
  321.     function init: JActivityManager_RunningServiceInfo; cdecl;  
  322.     { Properties }  
  323.     property CREATOR: JParcelable_Creator read _GetCREATOR;  
  324.     // Added in API level 5  
  325.     property FLAG_FOREGROUND: Integer read _GetFLAG_FOREGROUND;  
  326.     // Added in API level 5  
  327.     property FLAG_PERSISTENT_PROCESS: Integer read _GetFLAG_PERSISTENT_PROCESS;  
  328.     // Added in API level 5  
  329.     property FLAG_STARTED: Integer read _GetFLAG_STARTED;  
  330.     // Added in API level 5  
  331.     property FLAG_SYSTEM_PROCESS: Integer read _GetFLAG_SYSTEM_PROCESS;  
  332.   end;  
  333.   
  334.   [JavaSignature('android/app/ActivityManager$RunningServiceInfo')]  
  335.   JActivityManager_RunningServiceInfo = interface(JObject)  
  336.   ['{CEECA783-977A-4E16-8907-C4F65F25D168}']  
  337.     { Property Methods }  
  338.     function _GetactiveSince: Int64;  
  339.     procedure _SetactiveSince(Value: Int64);  
  340.     function _GetclientCount: Integer;  
  341.     procedure _SetclientCount(Value: Integer);  
  342.     function _GetclientLabel: Integer;  
  343.     procedure _SetclientLabel(Value: Integer);  
  344.     function _GetclientPackage: JString;  
  345.     procedure _SetclientPackage(Value: JString);  
  346.     function _GetcrashCount: Integer;  
  347.     procedure _SetcrashCount(Value: Integer);  
  348.     function _Getflags: Integer;  
  349.     procedure _Setflags(Value: Integer);  
  350.     function _Getforeground: Boolean;  
  351.     procedure _Setforeground(Value: Boolean);  
  352.     function _GetlastActivityTime: Int64;  
  353.     procedure _SetlastActivityTime(Value: Int64);  
  354.     function _Getpid: Integer;  
  355.     procedure _Setpid(Value: Integer);  
  356.     function _Getprocess: JString;  
  357.     procedure _Setprocess(Value: JString);  
  358.     function _Getrestarting: Int64;  
  359.     procedure _Setrestarting(Value: Int64);  
  360.     function _Getservice: JComponentName;  
  361.     procedure _Setservice(Value: JComponentName);  
  362.     function _Getstarted: Boolean;  
  363.     procedure _Setstarted(Value: Boolean);  
  364.     function _Getuid: Integer;  
  365.     procedure _Setuid(Value: Integer);  
  366.     { Methods }  
  367.     function describeContents: Integer; cdecl;  
  368.     procedure readFromParcel(source: JParcel); cdecl;  
  369.     procedure writeToParcel(dest: JParcel; flags: Integer); cdecl;  
  370.     { Properties }  
  371.     property activeSince: Int64 read _GetactiveSince write _SetactiveSince;  
  372.     property clientCount: Integer read _GetclientCount write _SetclientCount;  
  373.     // API level 5  
  374.     property clientLabel: Integer read _GetclientLabel write _SetclientLabel;  
  375.     // API level 5  
  376.     property clientPackage: JString read _GetclientPackage write _SetclientPackage;  
  377.     property crashCount: Integer read _GetcrashCount write _SetcrashCount;  
  378.     // API level 5  
  379.     property flags: Integer read _Getflags write _Setflags;  
  380.     property foreground: Boolean read _Getforeground write _Setforeground;  
  381.     property lastActivityTime: Int64 read _GetlastActivityTime write _SetlastActivityTime;  
  382.     property pid: Integer read _Getpid write _Setpid;  
  383.     property process: JString read _Getprocess write _Setprocess;  
  384.     property restarting: Int64 read _Getrestarting write _Setrestarting;  
  385.     property service: JComponentName read _Getservice write _Setservice;  
  386.     property started: Boolean read _Getstarted write _Setstarted;  
  387.     // API level 5  
  388.     property uid: Integer read _Getuid write _Setuid;  
  389.   end;  
  390.   TJActivityManager_RunningServiceInfo = class(TJavaGenericImport<JActivityManager_RunningServiceInfoClass,  
  391.     JActivityManager_RunningServiceInfo>) end;  
  392.   
  393. { http://developer.android.com/reference/android/app/ActivityManager.RunningTaskInfo.html 
  394.   Added in API level 1 }  
  395.   JActivityManager_RunningTaskInfoClass = interface(JObjectClass)  
  396.   ['{CB509FD6-FB15-495C-AFE8-DF705BFDD1CB}']  
  397.     { Property Methods }  
  398.     function _GetCREATOR: JParcelable_Creator;  
  399.     { Methods }  
  400.     function init: JActivityManager_RunningTaskInfo; cdecl;  
  401.     { Properties }  
  402.     property CREATOR: JParcelable_Creator read _GetCREATOR;  
  403.   end;  
  404.   
  405.   [JavaSignature('android/app/ActivityManager$RunningTaskInfo')]  
  406.   JActivityManager_RunningTaskInfo = interface(JObject)  
  407.   ['{48B0FF17-C6E7-46A9-8C4E-55186F86CE58}']  
  408.     { Property Methods }  
  409.     function _GetbaseActivity: JComponentName;  
  410.     procedure _SetbaseActivity(Value: JComponentName);  
  411.     function _Getdescription: JCharSequence;  
  412.     procedure _Setdescription(Value: JCharSequence);  
  413.     function _Getid: Integer;  
  414.     procedure _Setid(Value: Integer);  
  415.     function _GetnumActivities: Integer;  
  416.     procedure _SetnumActivities(Value: Integer);  
  417.     function _GetnumRunning: Integer;  
  418.     procedure _SetnumRunning(Value: Integer);  
  419.     function _Getthumbnail: JBitmap;  
  420.     procedure _Setthumbnail(Value: JBitmap);  
  421.     function _GettopActivity: JComponentName;  
  422.     procedure _SettopActivity(Value: JComponentName);  
  423.     { Methods }  
  424.     function describeContents: Integer; cdecl;  
  425.     procedure readFromParcel(source: JParcel); cdecl;  
  426.     procedure writeToParcel(dest: JParcel; flags: Integer); cdecl;  
  427.     { Properties }  
  428.     property baseActivity: JComponentName read _GetbaseActivity write _SetbaseActivity;  
  429.     property description: JCharSequence read _Getdescription write _Setdescription;  
  430.     property id: Integer read _Getid write _Setid;  
  431.     property numActivities: Integer read _GetnumActivities write _SetnumActivities;  
  432.     property numRunning: Integer read _GetnumRunning write _SetnumRunning;  
  433.     property thumbnail: JBitmap read _Getthumbnail write _Setthumbnail;  
  434.     property topActivity: JComponentName read _GettopActivity write _SettopActivity;  
  435.   end;  
  436.   TJActivityManager_RunningTaskInfo = class(TJavaGenericImport<JActivityManager_RunningTaskInfoClass,  
  437.     JActivityManager_RunningTaskInfo>) end;  
  438.   
  439. { http://developer.android.com/reference/android/app/ActivityManager.html 
  440.   Added in API level 1 }  
  441.   JActivityManagerClass = interface(JObjectClass)  
  442.   ['{DE9F8D5B-3354-4E29-86BA-E47715ECD75B}']  
  443.     { Property Methods }  
  444.     function _GetMOVE_TASK_NO_USER_ACTION: Integer;  
  445.     function _GetMOVE_TASK_WITH_HOME: Integer;  
  446.     function _GetRECENT_IGNORE_UNAVAILABLE: Integer;  
  447.     function _GetRECENT_WITH_EXCLUDED: Integer;  
  448.     { Methods }  
  449.     function init: JActivityManager; cdecl;  
  450.     // Added in API level 16  
  451.     procedure getMyMemoryState(outState: JActivityManager_RunningAppProcessInfo); cdecl;  
  452.     // Added in API level 11  
  453.     function isRunningInTestHarness: Boolean; cdecl;  
  454.     // Added in API level 8  
  455.     function isUserAMonkey: Boolean; cdecl;  
  456.     { Properties }  
  457.     // Added in API level 12  
  458.     property MOVE_TASK_NO_USER_ACTION: Integer read _GetMOVE_TASK_NO_USER_ACTION;  
  459.     // Added in API level 11  
  460.     property MOVE_TASK_WITH_HOME: Integer read _GetMOVE_TASK_WITH_HOME;  
  461.     // Added in API level 11  
  462.     property RECENT_IGNORE_UNAVAILABLE: Integer read _GetRECENT_IGNORE_UNAVAILABLE;  
  463.     property RECENT_WITH_EXCLUDEDread: Integer read _GetRECENT_WITH_EXCLUDED;  
  464.   end;  
  465.   
  466.   [JavaSignature('android/app/ActivityManager')]  
  467.   JActivityManager = interface(JObject)  
  468.   ['{AC5C42D6-E307-41EC-890A-DC846F528B0D}']  
  469.     { Methods }  
  470.     // Added in API level 3  
  471.     function getDeviceConfigurationInfo: JConfigurationInfo; cdecl;  
  472.     // Added in API level 11  
  473.     function getLargeMemoryClass: Integer; cdecl;  
  474.     // Added in API level 11  
  475.     function getLauncherLargeIconDensity: Integer; cdecl;  
  476.     // Added in API level 11  
  477.     function getLauncherLargeIconSize: Integer; cdecl;  
  478.     // Added in API level 5  
  479.     function getMemoryClass: Integer; cdecl;  
  480.     procedure getMemoryInfo(outInfo: JActivityManager_MemoryInfo); cdecl;  
  481.     // Added in API level 5  
  482.     function getProcessMemoryInfo(pids: TJavaArray<Integer>): TJavaObjectArray<JDebug_MemoryInfo>; cdecl;  
  483.     function getProcessesInErrorState: JList{<JActivityManager_ProcessErrorStateInfo>}; cdecl;  
  484.     function getRecentTasks(maxNum: Integer; flags: Integer): JList{<JActivityManager_RecentTaskInfo>}; cdecl;  
  485.     // Added in API level 3  
  486.     function getRunningAppProcesses: JList{<JActivityManager_RunningAppProcessInfo>}; cdecl;  
  487.     // Added in API level 5  
  488.     function getRunningServiceControlPanel(service: JComponentName): JPendingIntent; cdecl;  
  489.     function getRunningServices(maxNum: Integer): JList{<JActivityManager_RunningServiceInfo>}; cdecl;  
  490.     function getRunningTasks(maxNum: Integer): JList{<JActivityManager_RunningTaskInfo>}; cdecl;  
  491.     // Added in API level 8  
  492.     procedure killBackgroundProcesses(packageName: JString); cdecl;  
  493.     // Added in API level 16  
  494.     procedure moveTaskToFront(taskId: Integer; flags: Integer; options: JBundle); cdecl; overload;  
  495.     // Added in API level 11  
  496.     procedure moveTaskToFront(taskId: Integer; flags: Integer) cdecl; overload;  
  497.     // Added in API level 3  
  498.     procedure restartPackage(packageName: JString); cdecl;  
  499.   end;  
  500.   TJActivityManager = class(TJavaGenericImport<JActivityManagerClass, JActivityManager>) end;  
  501.   
  502. function GetActivityManager: JActivityManager;  
  503.   
  504. implementation  
  505.   
  506. function GetActivityManager: JActivityManager;  
  507. var  
  508.   LJO: JObject;  
  509. begin  
  510.   LJO := SharedActivity.getSystemService(TJContext.JavaClass.ACTIVITY_SERVICE);  
  511.   if not Assigned(LJO) then   
  512.     raise Exception.Create('Can not Access Activity Service!')  
  513.   else  
  514.     Result := TJActivityManager.Wrap((LJO as ILocalObject).GetObjectID);  
  515. end;  
  516.   
  517. end.  

一个列举正在运行的进程的例子:

[delphi] view plain copy
 
  1. procedure ListProcesses;  
  2. var  
  3.   LJL: JList;  
  4.   LIterator: JIterator;  
  5.   LJAR: JActivityManager_RunningAppProcessInfo;  
  6. begin  
  7.   LJL := GetActivityManager.getRunningAppProcesses;  
  8.   if Assigned(LJL) then  
  9.   begin  
  10.     LIterator := LJL.iterator;  
  11.     while LIterator.hasNext do  
  12.     begin  
  13.       LJAR := TJActivityManager_RunningAppProcessInfo.Wrap(  
  14.         (LIterator.next as ILocalObject).GetObjectID);  
  15.       // ShowMessage(JStringToString(LJAR.processName));  
  16.     end;  
  17.   end;  
  18. end;  


 

http://blog.csdn.net/flcop/article/details/17190009

posted @ 2017-06-19 20:16  findumars  Views(1265)  Comments(0)    收藏  举报