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

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

[delphi]view plaincopy

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

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

[delphi]view plaincopy

  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