Tuesday, 15 July 2014

ios - How to Identify that which app is running is in foreground? Looking for a solution which is acceptable by AppStore -


Develop an application where I need to get access to the application which is currently running on the foreground and tried I have been running all the processes on the device but I want to get information about the applications running in the foreground. And if I should try to do SBSSpringBoardServerPort then AppStore will not accept it.

  (NSArray *) Processes running {int mib [4] = {CTL_KERN,     KERN_PROC, KRN_ PROC_ALL, 0}; Size_t miblen = 4; Size_t size; Int st = sysctl (mb, mbillin, faucet, and size, zero, 0); Struct kinfo_proc * process = zero; Struct kinfo_proc * newprocess = NULL; Do {size = size = 10; Newprocess = realloc (process, size); If (! New Process) {If (Process) {Free (Process); } Return zero; } Process = new process; St = sysctl (mib, miblen, process, and size, zero, 0); } While (cents == -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]; (Int i = nprosas - 1; i> = 0; ii) {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, for zero]: [NSArray arrayWithObjects: @ "ProcessID", @ "Process name", zero]]; [ProcessID Release]; [ProcessName release]; [Array addObject: dict]; [Core release]; } Free (process); Return [Array Autorege]; }}} Return zero; }:  


No comments:

Post a Comment