delphi xe Android 判断自己程序是否是前台程序


本文整理自网络,侵删。

 

如果程序当前在前台,返回 True,否则返回 False。

 

function IsAppActive:Boolean;

var
  AList:JList;
  AProcess:JActivityManager_RunningAppProcessInfo;
  AName:JString;
  AIterator:JIterator;
begin
AList:=SharedActivityManager.getRunningAppProcesses;
AName:=SharedActivityContext.getPackageName;
Result:=False;
if Assigned(AList) then
  begin
  AIterator:=AList.iterator;
  while AIterator.hasNext do
    begin
    AProcess:=TJActivityManager_RunningAppProcessInfo.Wrap((AIterator.next as ILocalObject).GetObjectID);
    if AProcess.processName.equals(AName) then
      begin
      if AProcess.importance=TJActivityManager_RunningAppProcessInfo.JavaClass.IMPORTANCE_FOREGROUND then
        begin
        Result:=True;
        Break;
        end;
      end;
    end;
  end;
end;

相关阅读 >>

Delphi 窗口全屏

Delphi xe listbox 行高根据内容高度进行调速

Delphi vista和win7下如何弹出uac

Delphi编程之win10桌面图标设置

Delphi 字符串加密解密(不支持中文)

Delphi的idhttp报508 loop detected错误的原因

Delphi 新建文件夹函数

Delphi 世界时间转换

Delphi 操作“任务栏”

Delphi下对dbf文件进行物理删除

更多相关阅读请进入《Delphi》频道 >>



打赏

取消

感谢您的支持,我会继续努力的!

扫码支持
扫码打赏,您说多少就多少

打开支付宝扫一扫,即可进行扫码打赏哦

分享从这里开始,精彩与您同在

评论

管理员已关闭评论功能...