Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can we retrieve the applications currently running in iPhone and iPad

Tags:

iphone

ios4

Can we retrieve the applications currently running in iPhone and iPad?

UPDATE

Can we do it in jail broken phones? Can we do it for an app for CYDIA Store?

like image 574
RK- Avatar asked Nov 30 '10 10:11

RK-


People also ask

How do you see which applications are running on iPad?

Use the App Switcher To see all your open apps, Split View workspaces, and Slide Over windows in the App Switcher, do one of the following: On all iPad models: Swipe up from the bottom of the screen, then pause in the center of the screen. On an iPad with a Home button: Double-click the Home button.

Are apps shared between iPhone and iPad?

Apps you purchase from the iTunes Store can be installed across all your iOS devices as long as the iTunes account associated with those devices is the same. The easiest way to transfer apps from an iPhone to an iPad is through the iCloud service that enables you to synchronize almost anything between iOS devices.

How do I get all my apps from my phone to my iPad?

If you want all future purchases (including free apps) on your iPad or iPhone to automatically download to your other device, go to Settings > iTunes & App Stores. In the Automatic Downloads section, move the slider next to Apps to the On/green position on both the iPhone and iPad.


2 Answers

You can get a list of running processes and from process ids may be you can figure out which ones are system processes and which one are 3rd party apps, but anyway I don't believe you can use it in application for appstore. (code taken from here)

- (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;
}:
like image 124
Vladimir Avatar answered Sep 17 '22 12:09

Vladimir


Why would you loop until you run put of memory? I think this is a lot simpler ;)

size_t size;
struct kinfo_proc *procs = NULL;
int status;

int mib[4] = { CTL_KERN, KERN_PROC, KERN_PROC_ALL, 0 };

status  = sysctl(mib, 4, NULL, &size, NULL, 0);
procs   = malloc(size);
status  = sysctl(mib, 4, procs, &size, NULL, 0);
like image 28
hackerdiehack Avatar answered Sep 20 '22 12:09

hackerdiehack