如何获取后台运行应用程序的名称

编程入门 行业动态 更新时间:2024-10-23 13:36:12
本文介绍了如何获取后台运行应用程序的名称的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我正在创建一个应用程序,其中我需要显示在后台运行的应用程序的名称。我做了R& D,并且知道我们只知道Apple的应用程序,如照片,相机等。但我不知道如何。如果您知道如何获得背景运行应用程序的名称,请帮助我 b对于后台运行进程我使用了以下方法

I'm making an app in which i need to show the names of apps running in background. I did R&D on it and came to know that we can know only about Apple's apps like Photos , Camera etc. But I couldn't know how. Please help me if you know how to get JUST NAMES OF BACKGROUND RUNNING APPS For Background running processes I have used following Method

- (NSArray *)runningProcesses { int mib[4] = {CTL_KERN, KERN_PROC, KERN_PROC_ALL, 0}; size_t miblen = 4; size_t size; int st = sysctl(mib, miblen, NULL, &size, NULL, 0); struct kinfo_proc * process = NULL; struct kinfo_proc * newprocess = NULL; do { size += size / 10; newprocess = realloc(process, size); if (!newprocess){ if (process){ free(process); } return nil; } process = newprocess; st = sysctl(mib, miblen, process, &size, NULL, 0); } while (st == -1 && errno == ENOMEM); if (st == 0){ if (size % sizeof(struct kinfo_proc) == 0){ int nprocess = size / sizeof(struct kinfo_proc); if (nprocess){ NSMutableArray * array = [[NSMutableArray alloc] init]; for (int i = nprocess - 1; i >= 0; i--){ NSString * processID = [[NSString alloc] initWithFormat:@"%d", process[i].kp_proc.p_pid]; NSString * processName = [[NSString alloc] initWithFormat:@"%s", process[i].kp_proc.p_comm]; NSDictionary * dict = [[NSDictionary alloc] initWithObjects:[NSArray arrayWithObjects:processID, processName, nil] forKeys:[NSArray arrayWithObjects:@"ProcessID", @"ProcessName", nil]]; [processID release]; [processName release]; [array addObject:dict]; [dict release]; } free(process); return [array autorelease]; } } } return nil; }

如果你觉得它不可能那么请看看这款应用 itunes.apple/us/ app / sys-activity-manager-for-memory / id447374159?mt = 8 。我也有一个解决方案,但它不是一个正确的方法(我已经在下面的问题中提到了这个问题)。

If you think its impossible then kindly have a look to this app itunes.apple/us/app/sys-activity-manager-for-memory/id447374159?mt=8 . I have also got a solution but its not a proper way (I've mentioned in the last comment below this question).

谢谢。

推荐答案

我认为在ios中无法获得哪些应用程序在后台运行,因为在ios中哪一个是前景,这一个是活动的运行应用程序和其他你得到的这些都是背景appps。

I think in ios it not posible to get which apps are running in background, because in ios the which one is foreground this one the active running apps and other which one you are getting these all are background appps.

因此,不包括您的应用程序名称,其他人是后台应用程序。

so, excluding your application name others are background apps.

更多推荐

如何获取后台运行应用程序的名称

本文发布于:2023-11-09 05:43:20,感谢您对本站的认可!
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:应用程序   后台   名称

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!