【问题标题】:How to monitoring App running in the foreground in iOS8 or iOS9iOS8或iOS9如何监控前台运行的App
【发布时间】:2016-04-20 03:35:15
【问题描述】:

使用 PrivateFrameworks SpringBoardServices 在 iOS8、iOS9 中不工作, 我可以获取后台所有进程,但哪些进程在前台运行?

(void) monitoringFrontApp {
mach_port_t *port;
void *uikit = dlopen(SPRINGBOARDPATH, RTLD_LAZY);
int (*SBSSpringBoardServerPort)() =
dlsym(uikit, "SBSSpringBoardServerPort");
port =  (mach_port_t *)SBSSpringBoardServerPort();

//dynamic link sys mothed
void* (*SBFrontmostApplicationDisplayIdentifier)(mach_port_t* port,char * result) =
dlsym(uikit, "SBFrontmostApplicationDisplayIdentifier");
//call mothed
char frontmostAppS[256];
memset(frontmostAppS,sizeof(frontmostAppS),0);
SBFrontmostApplicationDisplayIdentifier(port,frontmostAppS);
NSString * app_id = [NSString stringWithUTF8String:frontmostAppS];

NSLog(@"front display app Identifier----%@", app_id);

//dynamic link sys mothed
CFStringRef (*SBSCopyLocalizedApplicationNameForDisplayIdentifier)(CFStringRef displayIdentifier) =
dlsym(uikit, "SBSCopyLocalizedApplicationNameForDisplayIdentifier");
//call mothed
CFStringRef locName = SBSCopyLocalizedApplicationNameForDisplayIdentifier((__bridge  CFStringRef)app_id);
NSString *app_name = [NSString stringWithFormat:@"%@",locName];
if (locName != NULL)CFRelease(locName);

 NSLog(@"front display app name----%@", app_name);

}

不适用于 iOS8 和 iOS9

【问题讨论】:

  • 请添加一些代码
  • 类 LSApplicationWorkspace_class= objc_getClass("LSApplicationWorkspace"); NSObject* 工作区 = [LSApplicationWorkspace_class performSelector:@selector(defaultWorkspace)]; NSLog(@"apps: %@", [workspace performSelector:@selector(allApplications)]);
  • @KUANGKAI 更新您的问题,不要将代码放入 cmets。

标签: ios iphone


【解决方案1】:

Google 分析将帮助您进行追踪。 https://www.google.co.in/analytics/#?modal_active=none

【讨论】:

    猜你喜欢
    • 2014-11-13
    • 1970-01-01
    • 1970-01-01
    • 2015-12-27
    • 2016-02-15
    • 1970-01-01
    • 2012-12-19
    • 2016-07-12
    • 1970-01-01
    相关资源
    最近更新 更多