Loading [MathJax]/jax/output/CommonHTML/config.js
前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
社区首页 >专栏 >Delphi Android ActivityManager

Delphi Android ActivityManager

作者头像
全栈程序员站长
发布于 2022-10-04 05:34:20
发布于 2022-10-04 05:34:20
2.1K10
代码可运行
举报
运行总次数:0
代码可运行

大家好,又见面了,我是你们的朋友全栈君。

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

代码语言:javascript
代码运行次数:0
运行
AI代码解释
复制
{
android.app.ActivityManager imported by flcop(zylove619@hotmail.com)
}
unit Androidapi.JNI.ActivityManager;
interface
uses
System.SysUtils,
FMX.Helpers.Android,
Androidapi.JNI.JavaTypes,
Androidapi.JNIBridge,
Androidapi.JNI.GraphicsContentViewText,
Androidapi.JNI.Os,
Androidapi.JNI.App;
type
{ Class forward declarations }
JDebug_MemoryInfo = interface;
JActivityManager_MemoryInfo = interface;
JActivityManager_ProcessErrorStateInfo = interface;
JActivityManager_RecentTaskInfo = interface;
JActivityManager_RunningAppProcessInfo = interface;
JActivityManager_RunningServiceInfo = interface;
JActivityManager_RunningTaskInfo = interface;
JActivityManager = interface;
{ http://developer.android.com/reference/android/os/Debug.MemoryInfo.html
Added in API level 1 }
JDebug_MemoryInfoClass = interface(JObjectClass)
['{E7545CF8-CFF5-40EE-9082-380FA48C4464}']
{ Property Methods }
function _GetCREATOR: JParcelable_Creator;
{ Methods }
function init: JDebug_MemoryInfo; cdecl;
{ Properties }
property CREATOR: JParcelable_Creator read _GetCREATOR;
end;
[JavaSignature('android/os/Debug$MemoryInfo')]
JDebug_MemoryInfo = interface(JObject)
['{577F2E29-A53C-4A3C-8548-21F6D6001EF6}']
{ Property Methods }
function _GetdalvikPrivateDirty: Integer;
procedure _SetdalvikPrivateDirty(Value: Integer);
function _GetdalvikPss: Integer;
procedure _SetdalvikPss(Value: Integer);
function _GetdalvikSharedDirty: Integer;
procedure _SetdalvikSharedDirty(Value: Integer);
function _GetnativePrivateDirty: Integer;
procedure _SetnativePrivateDirty(Value: Integer);
function _GetnativePss: Integer;
procedure _SetnativePss(Value: Integer);
function _GetnativeSharedDirty: Integer;
procedure _SetnativeSharedDirty(Value: Integer);
function _GetotherPrivateDirty: Integer;
procedure _SetotherPrivateDirty(Value: Integer);
function _GetotherPss: Integer;
procedure _SetotherPss(Value: Integer);
function _GetotherSharedDirty: Integer;
procedure _SetotherSharedDirty(Value: Integer);
{ Methods }
// Added in API level 5
function describeContents: Integer; cdecl;
// Added in API level 5
function getTotalPrivateDirty: Integer; cdecl;
// Added in API level 5
function getTotalPss: Integer; cdecl;
// Added in API level 5
function getTotalSharedDirty: Integer; cdecl;
// Added in API level 5
procedure readFromParcel(source: JParcel); cdecl;
// Added in API level 5
procedure writeToParcel(dest: JParcel; flags: Integer); cdecl;
{ Properties }
property dalvikPrivateDirty: Integer read _GetdalvikPrivateDirty write _SetdalvikPrivateDirty;
property dalvikPss: Integer read _GetdalvikPss write _SetdalvikPss;
property dalvikSharedDirty: Integer read _GetdalvikSharedDirty write _SetdalvikSharedDirty;
property nativePrivateDirty: Integer read _GetnativePrivateDirty write _SetnativePrivateDirty;
property nativePss: Integer read _GetnativePss write _SetnativePss;
property nativeSharedDirty: Integer read _GetnativeSharedDirty write _SetnativeSharedDirty;
property otherPrivateDirty: Integer read _GetotherPrivateDirty write _SetotherPrivateDirty;
property otherPss: Integer read _GetotherPss write _SetotherPss;
property otherSharedDirty: Integer read _GetotherSharedDirty write _SetotherSharedDirty;
end;
TJDebug_MemoryInfo = class(TJavaGenericImport<JDebug_MemoryInfoClass,
JDebug_MemoryInfo>) end;
{ http://developer.android.com/reference/android/app/ActivityManager.MemoryInfo.html
Added in API level 1 }
JActivityManager_MemoryInfoClass = interface(JObjectClass)
['{093B391C-56F6-47F9-96A5-CF4F4101F614}']
{ Property Methods }
function _GetCREATOR: JParcelable_Creator;
{ Methods }
function init: JActivityManager_MemoryInfo; cdecl;
{ Properties }
property CREATOR: JParcelable_Creator read _GetCREATOR;
end;
[JavaSignature('android/app/ActivityManager$MemoryInfo')]
JActivityManager_MemoryInfo = interface(JObject)
['{B6B801F7-3E6F-4BF9-9952-8356A7026725}']
{ Property Methods }
function _GetavailMem: Int64;
function _GetlowMemory: Boolean;
function _Getthreshold: Int64;
function _GettotalMem: Int64;
{ Methods }
function describeContents: Integer; cdecl;
procedure readFromParcel(source: JParcel); cdecl;
procedure writeToParcel(dest: JParcel; flags: Integer); cdecl;
{ Properties }
property availMem: Int64 read _GetavailMem;
property lowMemory: Boolean read _GetlowMemory;
property threshold: Int64 read _Getthreshold;
// Added in API level 16
property totalMem: Int64 read _GettotalMem;
end;
TJActivityManager_MemoryInfo = class(TJavaGenericImport<JActivityManager_MemoryInfoClass,
JActivityManager_MemoryInfo>) end;
{ http://developer.android.com/reference/android/app/ActivityManager.ProcessErrorStateInfo.html
Added in API level 1 }
JActivityManager_ProcessErrorStateInfoClass = interface(JObjectClass)
['{B2DDD02D-B205-4412-89B7-418BC28DA58D}']
{ Property Methods }
function _GetCREATOR: JParcelable_Creator;
function _GetCRASHED: Integer;
function _GetNOT_RESPONDING: Integer;
function _GetNO_ERROR: Integer;
{ Methods }
function init: JActivityManager_ProcessErrorStateInfo; cdecl;
{ Properties }
property CREATOR: JParcelable_Creator read _GetCREATOR;
property CRASHED: Integer read _GetCRASHED;
property NOT_RESPONDING: Integer read _GetNOT_RESPONDING;
property NO_ERROR: Integer read _GetNO_ERROR;
end;
[JavaSignature('android/app/ActivityManager$ProcessErrorStateInfo')]
JActivityManager_ProcessErrorStateInfo = interface(JObject)
['{7406BE27-6395-44F4-8CC7-633375617A2A}']
{ Property Methods }
function _Getcondition: Integer;
procedure _Setcondition(Value: Integer);
function _GetcrashData: TJavaArray<Byte>;
procedure _SetcrashData(Value: TJavaArray<Byte>);
function _GetlongMsg: JString;
procedure _SetlongMsg(Value: JString);
function _Getpid: Integer;
procedure _Setpid(Value: Integer);
function _GetprocessName: JString;
procedure _SetprocessName(Value: JString);
function _GetshortMsg: JString;
procedure _SetshortMsg(Value: JString);
function _GetstackTrace: JString;
procedure _SetstackTrace(Value: JString);
function _Gettag: JString;
procedure _Settag(Value: JString);
function _Getuid: Integer;
procedure _Setuid(Value: Integer);
{ Methods }
function describeContents: Integer; cdecl;
procedure readFromParcel(source: JParcel); cdecl;
procedure writeToParcel(dest: JParcel; flags: Integer); cdecl;
{ Properties }
property condition: Integer read _Getcondition write _Setcondition;
property crashData: TJavaArray<Byte> read _GetcrashData write _SetcrashData;
property longMsg: JString read _GetlongMsg write _SetlongMsg;
property pid: Integer read _Getpid write _Setpid;
property processName: JString read _GetprocessName write _SetprocessName;
property shortMsg: JString read _GetshortMsg write _SetshortMsg;
// Added in API level 8
property stackTrace: JString read _GetstackTrace write _SetstackTrace;
property tag: JString read _Gettag write _Settag;
property uid: Integer read _Getuid write _Setuid;
end;
TJActivityManager_ProcessErrorStateInfo = class(TJavaGenericImport<JActivityManager_ProcessErrorStateInfoClass,
JActivityManager_ProcessErrorStateInfo>) end;
{ http://developer.android.com/reference/android/app/ActivityManager.RecentTaskInfo.html
Added in API level 1 }
JActivityManager_RecentTaskInfoClass = interface(JObjectClass)
['{4AE6025B-0BEA-4D81-8E3F-4EC6F7BA8EEF}']
{ Property Methods }
function _GetCREATOR: JParcelable_Creator;
{ Methods }
function init: JActivityManager_RecentTaskInfo; cdecl;
{ Properties }
property CREATOR: JParcelable_Creator read _GetCREATOR;
end;
[JavaSignature('android/app/ActivityManager$RecentTaskInfo')]
JActivityManager_RecentTaskInfo = interface(JObject)
['{02A5EDBF-B7CC-4C63-BACD-0F1A195C6969}']
{ Property Methods }
function _GetbaseIntent: JIntent;
procedure _SetbaseIntent(Value: JIntent);
function _Getdescription: JCharSequence;
procedure _Setdescription(Value: JCharSequence);
function _Getid: Integer;
procedure _Setid(Value: Integer);
function _GetorigActivity: JComponentName;
procedure _SetorigActivity(Value: JComponentName);
function _GetpersistentId: Integer;
procedure _SetpersistentId(Value: Integer);
{ Methods }
function describeContents: Integer; cdecl;
procedure readFromParcel(source: JParcel); cdecl;
procedure writeToParcel(dest: JParcel; flags: Integer); cdecl;
{ Properties }
property baseIntent: JIntent read _GetbaseIntent write _SetbaseIntent;
// Added in API level 11
property description: JCharSequence read _Getdescription write _Setdescription;
property id: Integer read _Getid write _Setid;
property origActivity: JComponentName read _GetorigActivity write _SetorigActivity;
// Added in API level 12
property persistentId: Integer read _GetpersistentId write _SetpersistentId;
end;
TJActivityManager_RecentTaskInfo = class(TJavaGenericImport<JActivityManager_RecentTaskInfoClass,
JActivityManager_RecentTaskInfo>) end;
{ http://developer.android.com/reference/android/app/ActivityManager.RunningAppProcessInfo.html
Added in API level 3 }
JActivityManager_RunningAppProcessInfoClass = interface(JObjectClass)
['{F24C0121-C062-4A2B-9363-E97A50E2FC41}']
{ Property Methods }
function _GetCREATOR: JParcelable_Creator;
function _GetIMPORTANCE_BACKGROUND: Integer;
function _GetIMPORTANCE_EMPTY: Integer;
function _GetIMPORTANCE_FOREGROUND: Integer;
function _GetIMPORTANCE_PERCEPTIBLE: Integer;
function _GetIMPORTANCE_SERVICE: Integer;
function _GetIMPORTANCE_VISIBLE: Integer;
function _GetREASON_PROVIDER_IN_USE: Integer;
function _GetREASON_SERVICE_IN_USE: Integer;
function _GetREASON_UNKNOWN: Integer;
{ Methods }
function init: JActivityManager_RunningAppProcessInfo; cdecl; overload;
function init(pProcessName: JString; pPid: Integer; pArr: TJavaObjectArray<JString>):
JActivityManager_RunningAppProcessInfo; cdecl; overload;
{ Properties }
property CREATOR: JParcelable_Creator read _GetCREATOR;
property IMPORTANCE_BACKGROUND: Integer read _GetIMPORTANCE_BACKGROUND;
property IMPORTANCE_EMPTY: Integer read _GetIMPORTANCE_EMPTY;
property IMPORTANCE_FOREGROUND: Integer read _GetIMPORTANCE_FOREGROUND;
// Added in API level 9
property IMPORTANCE_PERCEPTIBLE: Integer read _GetIMPORTANCE_PERCEPTIBLE;
property IMPORTANCE_SERVICE: Integer read _GetIMPORTANCE_SERVICE;
property IMPORTANCE_VISIBLE: Integer read _GetIMPORTANCE_VISIBLE;
// Added in API level 5
property REASON_PROVIDER_IN_USE: Integer read _GetREASON_PROVIDER_IN_USE;
// Added in API level 5
property REASON_SERVICE_IN_USE: Integer read _GetREASON_SERVICE_IN_USE;
// Added in API level 5
property REASON_UNKNOWN: Integer read _GetREASON_UNKNOWN;
end;
[JavaSignature('android/app/ActivityManager$RunningAppProcessInfo')]
JActivityManager_RunningAppProcessInfo = interface(JObject)
['{3E72F05C-6CF2-4971-B34B-5FE4C414913D}']
{ Property Methods }
function _Getimportance: Integer;
procedure _Setimportance(Value: Integer);
function _GetimportanceReasonCode: Integer;
procedure _SetimportanceReasonCode(Value: Integer);
function _GetimportanceReasonComponent: JComponentName;
procedure _SetimportanceReasonComponent(Value: JComponentName);
function _GetimportanceReasonPid: Integer;
procedure _SetimportanceReasonPid(Value: Integer);
function _GetlastTrimLevel: Integer;
procedure _SetlastTrimLevel(Value: Integer);
function _Getlru: Integer;
procedure _Setlru(Value: Integer);
function _Getpid: Integer;
procedure _Setpid(Value: Integer);
function _GetpkgList: TJavaObjectArray<JString>;
procedure _SetpkgList(Value: TJavaObjectArray<JString>);
function _GetprocessName: JString;
procedure _SetprocessName(Value: JString);
function _Getuid: Integer;
procedure _Setuid(Value: Integer);
{ Methods }
function describeContents: Integer; cdecl;
procedure readFromParcel(source: JParcel); cdecl;
procedure writeToParcel(dest: JParcel; flags: Integer); cdecl;
{ Properties }
property importance: Integer read _Getimportance write _Setimportance;
// Added in API level 5
property importanceReasonCode: Integer read _GetimportanceReasonCode write _SetimportanceReasonCode;
// Added in API level 5
property importanceReasonComponent: JComponentName read _GetimportanceReasonComponent write _SetimportanceReasonComponent;
// Added in API level 5
property importanceReasonPid: Integer read _GetimportanceReasonPid write _SetimportanceReasonPid;
// Added in API level 16
property lastTrimLevel: Integer read _GetlastTrimLevel write _SetlastTrimLevel;
property lru: Integer read _Getlru write _Setlru;
property pid: Integer read _Getpid write _Setpid;
property pkgList: TJavaObjectArray<JString> read _GetpkgList write _SetpkgList;
property processName: JString read _GetprocessName write _SetprocessName;
// Added in API level 5
property uid: Integer read _Getuid write _Setuid;
end;
TJActivityManager_RunningAppProcessInfo = class(TJavaGenericImport<JActivityManager_RunningAppProcessInfoClass,
JActivityManager_RunningAppProcessInfo>) end;
{ http://developer.android.com/reference/android/app/ActivityManager.RunningServiceInfo.html
Added in API level 1 }
JActivityManager_RunningServiceInfoClass = interface(JObjectClass)
['{8A01CD6D-5177-4F74-A65E-20BAC0B76F0F}']
{ Property Methods }
function _GetCREATOR: JParcelable_Creator;
function _GetFLAG_FOREGROUND: Integer;
function _GetFLAG_PERSISTENT_PROCESS: Integer;
function _GetFLAG_STARTED: Integer;
function _GetFLAG_SYSTEM_PROCESS: Integer;
{ Methods }
function init: JActivityManager_RunningServiceInfo; cdecl;
{ Properties }
property CREATOR: JParcelable_Creator read _GetCREATOR;
// Added in API level 5
property FLAG_FOREGROUND: Integer read _GetFLAG_FOREGROUND;
// Added in API level 5
property FLAG_PERSISTENT_PROCESS: Integer read _GetFLAG_PERSISTENT_PROCESS;
// Added in API level 5
property FLAG_STARTED: Integer read _GetFLAG_STARTED;
// Added in API level 5
property FLAG_SYSTEM_PROCESS: Integer read _GetFLAG_SYSTEM_PROCESS;
end;
[JavaSignature('android/app/ActivityManager$RunningServiceInfo')]
JActivityManager_RunningServiceInfo = interface(JObject)
['{CEECA783-977A-4E16-8907-C4F65F25D168}']
{ Property Methods }
function _GetactiveSince: Int64;
procedure _SetactiveSince(Value: Int64);
function _GetclientCount: Integer;
procedure _SetclientCount(Value: Integer);
function _GetclientLabel: Integer;
procedure _SetclientLabel(Value: Integer);
function _GetclientPackage: JString;
procedure _SetclientPackage(Value: JString);
function _GetcrashCount: Integer;
procedure _SetcrashCount(Value: Integer);
function _Getflags: Integer;
procedure _Setflags(Value: Integer);
function _Getforeground: Boolean;
procedure _Setforeground(Value: Boolean);
function _GetlastActivityTime: Int64;
procedure _SetlastActivityTime(Value: Int64);
function _Getpid: Integer;
procedure _Setpid(Value: Integer);
function _Getprocess: JString;
procedure _Setprocess(Value: JString);
function _Getrestarting: Int64;
procedure _Setrestarting(Value: Int64);
function _Getservice: JComponentName;
procedure _Setservice(Value: JComponentName);
function _Getstarted: Boolean;
procedure _Setstarted(Value: Boolean);
function _Getuid: Integer;
procedure _Setuid(Value: Integer);
{ Methods }
function describeContents: Integer; cdecl;
procedure readFromParcel(source: JParcel); cdecl;
procedure writeToParcel(dest: JParcel; flags: Integer); cdecl;
{ Properties }
property activeSince: Int64 read _GetactiveSince write _SetactiveSince;
property clientCount: Integer read _GetclientCount write _SetclientCount;
// API level 5
property clientLabel: Integer read _GetclientLabel write _SetclientLabel;
// API level 5
property clientPackage: JString read _GetclientPackage write _SetclientPackage;
property crashCount: Integer read _GetcrashCount write _SetcrashCount;
// API level 5
property flags: Integer read _Getflags write _Setflags;
property foreground: Boolean read _Getforeground write _Setforeground;
property lastActivityTime: Int64 read _GetlastActivityTime write _SetlastActivityTime;
property pid: Integer read _Getpid write _Setpid;
property process: JString read _Getprocess write _Setprocess;
property restarting: Int64 read _Getrestarting write _Setrestarting;
property service: JComponentName read _Getservice write _Setservice;
property started: Boolean read _Getstarted write _Setstarted;
// API level 5
property uid: Integer read _Getuid write _Setuid;
end;
TJActivityManager_RunningServiceInfo = class(TJavaGenericImport<JActivityManager_RunningServiceInfoClass,
JActivityManager_RunningServiceInfo>) end;
{ http://developer.android.com/reference/android/app/ActivityManager.RunningTaskInfo.html
Added in API level 1 }
JActivityManager_RunningTaskInfoClass = interface(JObjectClass)
['{CB509FD6-FB15-495C-AFE8-DF705BFDD1CB}']
{ Property Methods }
function _GetCREATOR: JParcelable_Creator;
{ Methods }
function init: JActivityManager_RunningTaskInfo; cdecl;
{ Properties }
property CREATOR: JParcelable_Creator read _GetCREATOR;
end;
[JavaSignature('android/app/ActivityManager$RunningTaskInfo')]
JActivityManager_RunningTaskInfo = interface(JObject)
['{48B0FF17-C6E7-46A9-8C4E-55186F86CE58}']
{ Property Methods }
function _GetbaseActivity: JComponentName;
procedure _SetbaseActivity(Value: JComponentName);
function _Getdescription: JCharSequence;
procedure _Setdescription(Value: JCharSequence);
function _Getid: Integer;
procedure _Setid(Value: Integer);
function _GetnumActivities: Integer;
procedure _SetnumActivities(Value: Integer);
function _GetnumRunning: Integer;
procedure _SetnumRunning(Value: Integer);
function _Getthumbnail: JBitmap;
procedure _Setthumbnail(Value: JBitmap);
function _GettopActivity: JComponentName;
procedure _SettopActivity(Value: JComponentName);
{ Methods }
function describeContents: Integer; cdecl;
procedure readFromParcel(source: JParcel); cdecl;
procedure writeToParcel(dest: JParcel; flags: Integer); cdecl;
{ Properties }
property baseActivity: JComponentName read _GetbaseActivity write _SetbaseActivity;
property description: JCharSequence read _Getdescription write _Setdescription;
property id: Integer read _Getid write _Setid;
property numActivities: Integer read _GetnumActivities write _SetnumActivities;
property numRunning: Integer read _GetnumRunning write _SetnumRunning;
property thumbnail: JBitmap read _Getthumbnail write _Setthumbnail;
property topActivity: JComponentName read _GettopActivity write _SettopActivity;
end;
TJActivityManager_RunningTaskInfo = class(TJavaGenericImport<JActivityManager_RunningTaskInfoClass,
JActivityManager_RunningTaskInfo>) end;
{ http://developer.android.com/reference/android/app/ActivityManager.html
Added in API level 1 }
JActivityManagerClass = interface(JObjectClass)
['{DE9F8D5B-3354-4E29-86BA-E47715ECD75B}']
{ Property Methods }
function _GetMOVE_TASK_NO_USER_ACTION: Integer;
function _GetMOVE_TASK_WITH_HOME: Integer;
function _GetRECENT_IGNORE_UNAVAILABLE: Integer;
function _GetRECENT_WITH_EXCLUDED: Integer;
{ Methods }
function init: JActivityManager; cdecl;
// Added in API level 16
procedure getMyMemoryState(outState: JActivityManager_RunningAppProcessInfo); cdecl;
// Added in API level 11
function isRunningInTestHarness: Boolean; cdecl;
// Added in API level 8
function isUserAMonkey: Boolean; cdecl;
{ Properties }
// Added in API level 12
property MOVE_TASK_NO_USER_ACTION: Integer read _GetMOVE_TASK_NO_USER_ACTION;
// Added in API level 11
property MOVE_TASK_WITH_HOME: Integer read _GetMOVE_TASK_WITH_HOME;
// Added in API level 11
property RECENT_IGNORE_UNAVAILABLE: Integer read _GetRECENT_IGNORE_UNAVAILABLE;
property RECENT_WITH_EXCLUDEDread: Integer read _GetRECENT_WITH_EXCLUDED;
end;
[JavaSignature('android/app/ActivityManager')]
JActivityManager = interface(JObject)
['{AC5C42D6-E307-41EC-890A-DC846F528B0D}']
{ Methods }
// Added in API level 3
function getDeviceConfigurationInfo: JConfigurationInfo; cdecl;
// Added in API level 11
function getLargeMemoryClass: Integer; cdecl;
// Added in API level 11
function getLauncherLargeIconDensity: Integer; cdecl;
// Added in API level 11
function getLauncherLargeIconSize: Integer; cdecl;
// Added in API level 5
function getMemoryClass: Integer; cdecl;
procedure getMemoryInfo(outInfo: JActivityManager_MemoryInfo); cdecl;
// Added in API level 5
function getProcessMemoryInfo(pids: TJavaArray<Integer>): TJavaObjectArray<JDebug_MemoryInfo>; cdecl;
function getProcessesInErrorState: JList{<JActivityManager_ProcessErrorStateInfo>}; cdecl;
function getRecentTasks(maxNum: Integer; flags: Integer): JList{<JActivityManager_RecentTaskInfo>}; cdecl;
// Added in API level 3
function getRunningAppProcesses: JList{<JActivityManager_RunningAppProcessInfo>}; cdecl;
// Added in API level 5
function getRunningServiceControlPanel(service: JComponentName): JPendingIntent; cdecl;
function getRunningServices(maxNum: Integer): JList{<JActivityManager_RunningServiceInfo>}; cdecl;
function getRunningTasks(maxNum: Integer): JList{<JActivityManager_RunningTaskInfo>}; cdecl;
// Added in API level 8
procedure killBackgroundProcesses(packageName: JString); cdecl;
// Added in API level 16
procedure moveTaskToFront(taskId: Integer; flags: Integer; options: JBundle); cdecl; overload;
// Added in API level 11
procedure moveTaskToFront(taskId: Integer; flags: Integer) cdecl; overload;
// Added in API level 3
procedure restartPackage(packageName: JString); cdecl;
end;
TJActivityManager = class(TJavaGenericImport<JActivityManagerClass, JActivityManager>) end;
function GetActivityManager: JActivityManager;
implementation
function GetActivityManager: JActivityManager;
var
LJO: JObject;
begin
LJO := SharedActivity.getSystemService(TJContext.JavaClass.ACTIVITY_SERVICE);
  if not Assigned(LJO) then 
    raise Exception.Create('Can not Access Activity Service!')
  else
    Result := TJActivityManager.Wrap((LJO as ILocalObject).GetObjectID);
end;
end.

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

代码语言:javascript
代码运行次数:0
运行
AI代码解释
复制
procedure ListProcesses;
var
  LJL: JList;
  LIterator: JIterator;
  LJAR: JActivityManager_RunningAppProcessInfo;
begin
  LJL := GetActivityManager.getRunningAppProcesses;
  if Assigned(LJL) then
  begin
    LIterator := LJL.iterator;
    while LIterator.hasNext do
    begin
      LJAR := TJActivityManager_RunningAppProcessInfo.Wrap(
        (LIterator.next as ILocalObject).GetObjectID);
      // ShowMessage(JStringToString(LJAR.processName));
    end;
  end;
end;

版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 举报,一经查实,本站将立刻删除。

本文参与 腾讯云自媒体同步曝光计划,分享自作者个人站点/博客。
原始发表:2022年9月6日 下,如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 作者个人站点/博客 前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体同步曝光计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
1 条评论
热度
最新
博主你好 求告知文件密码
博主你好 求告知文件密码
回复回复点赞举报
推荐阅读
编辑精选文章
换一批
android activitymanagerservice_安卓开发API
Android中Java层的ActivityManager类中封装了很多API,可以供我们查询当前系统的很多信息,包括:内存、进程(Process)、任务栈(Task)、服务(Service)等的相关信息。
全栈程序员站长
2022/10/04
4580
安卓学习之-ActivityManager
获取方法 ActivityManager mActivityManager (ActivityManager)getSystemService(Context.ACTIVITY_SERVICE);
全栈程序员站长
2022/10/04
6450
android activitymanager 系统api_Android view
ActivityManager服务是对Activity管理、运行时功能管理和运行时数据结构的封装,进程(Process)、应用程序/包、服务(Service)、任务(Task)信息等。包括以下功能:
全栈程序员站长
2022/10/04
5910
android activitymanager 系统api_Android view
基于android的_android studio创建activity
Android 如何判断一个应用在运行 在一个应用中,或一个Service 、Receiver中判断一个应用是否正在运行,以便进行一些相关的处理。 这个时候我们需要得到一个ActivityManager,这个Manager顾名思意就是管理Activity的,它有一个方法叫getRunningTasks,可以得到当前系统正在运行的Task的列表,代码如下: ActivityManager am = (ActivityManager)context.getSystemService(Context.
全栈程序员站长
2022/10/04
8500
ActivityManager 管理Activity[通俗易懂]
参考:https://www.jianshu.com/p/063fae89206b https://blog.csdn.net/qq_38520096/article/details/82109948 https://blog.csdn.net/lanye11/article/details/52221359
全栈程序员站长
2022/10/04
7130
android进程 清理及activity栈管理
MainActivity如下: package come.on;   import android.app.Activity;   import android.content.Context;   import android.content.Intent;   import android.os.Bundle;   import android.view.View;   import android.view.View.OnClickListener;   import android.widget
xiangzhihong
2018/01/29
1.5K0
activity详解_activity教程
Activity可以获取运行中的应用信息,可以获取到servcie,process,app,memory,Task信息等。
全栈程序员站长
2022/10/04
1.1K0
Android中ActivityManager学习笔记(1)-MemoryInfo「建议收藏」
与系统中所有的Activity进行交互的类。官网一句话解释了这个东西,但是有点随意了。ActivityManager的作用很多,我们通过它获得内存信息,进程信息,还可以终止某个进程。当然啦,只能终止用户的进程,系统的进程是杀死不了的。下面我通过实例,一步一步学习它的具体作用,我也是刚学,不能从宏观的角度给大家解释清楚它的具体作用。希望通过程序一步一步的写下去,其每个方法的作用也就清楚了,从而我们就知道它能干什么啦。语言组织能力差,所以就用代码来解释吧。
全栈程序员站长
2022/10/29
7760
Android中ActivityManager学习笔记(1)-MemoryInfo「建议收藏」
Android ActivityManager
ActivityManager虽然名为Activity管理器,其实际功能比类名描述的广泛,定义的方法涵盖了内存、进程、任务、设备等相关功能。因此,将ActivityManager理解为AppManager,更符合这个类。
大公爵
2022/11/02
6890
Android检测Activity或者Service是否运行
需求:假设我们的APP有3个页面AActivity,BActivity,CActivity,我们的APP需要一直运行在前台(特殊设备),要求实现一个监控服务,来监视APP是否运行,如果有3个页面都不运行了就说明这个APP已经挂掉了,否则说明APP在运行状态,不做处理,挂掉之后,我们需要重新启动App来让它继续处理运行状态,对外暴露一个来停止监控服务的广播,这样我们想停止监控服务时,发送一个广播即可。
程序员飞飞
2020/02/27
2.7K0
任务管理器(ActivityManager)
任务管理器(ActivityManager) Android中ActivityManager类似于Windows下的任务管理器,能得到正在运行程序的内容等信息 List getRunningServices(int maxNum) Return a list of the services that are currently running. 这个maxNum是指返回的这个集合的最大值 可以利用ActivityManager去判断当前某个服务是否正在运行。 List getRunni
xiangzhihong
2018/01/26
2.2K0
Android 点击通知栏消息打开activity,并判断app是否运行
android的通知栏消息点击事件如果是打开一个activity时,我们要考虑两种情况:
程思扬
2022/01/10
3.5K0
【Android】如何知道某个Activity是否在前台?
转载自zrong's blog 有一个Android应用包含包含一个后台程序,该程序会定期连接服务器来实现自定义信息的推送。但是,当这个应用处于前台的时候,后台程序就没有必要连接服务器了。这样可以节省网络资源,也更省电。 用什么方法知道该应用是否处于前台呢? 网上搜到的方法大多数都是使用下面的代码: ActivityManager am = (ActivityManager) this.getSystemService(ACTIVITY_SERVICE); //获得task列表 List<ActivityM
Gavin-ZYX
2018/05/18
1.6K0
满足合规的关于“只在应用主进程”中做初始化操作的判断逻辑
package com.tencent.qcloud.tim.demo; import android.app.ActivityManager; import android.content.Context; import android.util.Log; import java.util.List; public class SessionWrapper { private static final String TAG = SessionWrapper.class.getSimpleNa
Junker
2022/02/18
6250
Android获取Activity(应用)的执行状态及其它信息[通俗易懂]
发布者:全栈程序员栈长,转载请注明出处:https://javaforall.cn/116351.html原文链接:https://javaforall.cn
全栈程序员站长
2022/07/07
9560
Delphi类型和引用
概要介绍: 类类型和下面要讲到的类引用类型是一种特殊的数据类型,是Object Pascal面向对象编程的基础。  一:类类型概述 和以前介绍的几种数据类型相比,类类型具有如下特点: 类类型的成员可以是不同的数据类型,这一点跟记录类型相似,因此,类类型首先是由不同的字段 组成的。 类类型除了包含数据以外,还包含了操纵数据的方法及特性。类类型把数据和方法封装在一起。 类类型具有可继承性,所谓继承就是一个新的类类型,不必什么都从新定义,只需要继承一个已有 的类型再加上自己的成员就构成一个新的类类型。事实上Delphi中所有的元件都是从一些共同的祖先类 继承下来的,利用类的可继承性,您可以编写您自己的类元件,并把它加到Delphi的环境中去。 被继承的类我们称为基类,继承下来的类我们称为派生类,基类的成员自动成为派生类的成员。类 的继承具有传递性,例如假设T3继承了T2,而T2又是继承了T1,可以认为T3也继承T1。在Delphi中,所 有的类都是从一个共同的类TObject继承下来的,TObject类的声明在System单元中,它定义了一些操纵 类的最基本的方法,因此,Tobject也被称为缺省祖先类。 TObject是一个抽象类,它的派生类可以对TObject中的方法重载,包括对它的构造 Create 和析构 Destory的重载。 二:类类型的声明 类类型的声明比较复杂,其语法如下: Type 类=class(基类) [成员列表] End; 从以上语法可以看出,类类型可以指定一个祖先类型,表示该类型是从这个基类继承下来,如: Type TClass=Class(TObject) 这个例子,声明了一个名叫TClass的类类型,它是从类TObject继承下来的。注意,在Delphi中,类 名一般都是以T打头,以区别于其它数据类型。如果省略了指定基类,则表明直接从TObject继承下来。 成员列表的定义是这样 字段定义 方法定义 属性定义 类类型可以有三类成员分别是字段、方法、特性。字段的声明类型于记录类型中字段的声明,类类 型中的方法又可以分为4类,分别是构造、析构、过程和函数。分别用 Constructor、 Destructor、 Procedure、Function这4个保留字声明,类类型中的特性用保留字Property来声明,一个典型的类类型 示例如下: Type TClass=Class Private FX,FY,FZ:Integer; FS:String[128]; Public Constructor Create(X,Y,Z:Integer;S:string); Destrutor Destroy;override; Procedure Display;Virtual; Function SetStr(const Value:string); Publish Property Caption:String read FS Write SetStr; End; 上例中,声明了4个字段,数据类型分别是Integer和String。在Delphi中,一般私有变量字段都以 F打头。并且声明了一个构造CREATE,一个析构Destroy,一个过程Display,一个函数SetStr。另外还声 明了一个属性Caption。其它的语法元素如Private、Public等将在后面介绍。 注意:跟其它数据类型不同的是,类类型的声明只能出现在程序的Type区,而其它数据类型则可以 在Var区或过程或函数或方法的Begin语句之前声明。因此类类型的作用域总是全局的。 顺便提一下,类类型包括包含类类型分量的构造类型不能作为文件类型的基类型。 三:类类型的字段 类类型中的字段也就是类的数据部分,其声明方法同记录中字段的声明语法相似: 标识符:类型 其中字段的类型可以是各种数据类型,甚至是另一个类类型。 要访问对象的某个字段,跟访问记录变量中的字段类似,是用对象名加小圆点和字段名。 四:类类型的方法 类类型中的方法是个特定的名称,从形式上看也不过是一些过程或函数,不同的是方法是在类类型内部 声明的并只操纵类本身,因此在Object Pascal中方法有其特定含义。我们姑且都称它为方法。 方法的声明和定义 方法定义 方法首部;方法指示字 方法的声明跟变通的过程或函数的声明既相似也有不同的地方,相似的是声明时只需写出方法的首 部,不同的是声明方法时可以加上方法指示字。 方法分为4种
Vaccae
2019/07/24
2.6K0
Delphi使用NativeXml处理XML(二)
4.1.类(Classes) 4.1.1.TComponentAccess类   TComponentAccess = class(TComponent) 4.1.1.1.ComponentState   property ComponentState; 4.1.1.2.SetComponentState   procedure SetComponentState(const AState: TComponentState); 4.1.2.TNativeXml类   TNativeXml = class(TPersistent)   TNativeXml是XML文件的载体。创建一个TNativeXml,然后使用方法LoadFromFile、LoadFromStream或ReadFromString加载XML文档到内存中。或者从头开始使用Root.NodeNew添加节点,并最终SaveToFile和SaveToStream保存结果为一个XML文档。用属性Xmlformat = xfReadable确保缩进(易读)输出。 4.1.2.1.AbortParsing   property AbortParsing: boolean;   如果您使用一个SAX-like方式的OnNodeNew和OnNodeLoaded事件,并要中止解析过程,设置AbortParsing为True。例如:
Vaccae
2019/07/25
1.5K0
Android开发笔记(七十九)资源与权限校验
因为移动设备的硬件配置各不相同,为了防止使用了不存在的设备资源,所以要对设备的硬件情况进行检查。一般情况下,前置摄像头、部分传感器在低端手机上是没有的,像SD卡也可能因为用户没插卡使得找不到SD卡资源。下面是校验这些硬件设备的说明:
aqi00
2019/01/18
5900
delphi使用bcb的c++ .obj .o,lazarus x64内联汇编,att和intel
The {$ASMMODE XXX} directive informs the compiler what kind of assembler it can expect in an asm block. The XXX should be replaced by one of the following:
战神伽罗
2019/07/24
3.5K0
delphi使用bcb的c++ .obj .o,lazarus x64内联汇编,att和intel
Android开发笔记(八十)运行状态检查
大家都知道刻舟求剑的寓言故事,说的是事物是发展变化着的,如果拘泥于原来的情况,那随着情况的改变,就不会得到预期的结果。同样,影响app运行的因素,并不只是外部环境(如硬件、系统、权限等等),还包括app自身的运行信息。如果app的运行状态发生了变化,那么原先处理正确的逻辑也可能处理失败,所以在特定的情况下,我们得对app的运行情况进行检查。
aqi00
2019/01/18
6360
相关推荐
android activitymanagerservice_安卓开发API
更多 >
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档
本文部分代码块支持一键运行,欢迎体验
本文部分代码块支持一键运行,欢迎体验