2011年9月17日 星期六

iPhone iOS4 fast app switching and stay background util reboot

*** Only work at iOS4 ***

Remeber [NSThead sleepForTimeInterval:N] N don't too heavy and keep the value between 2~5.



And your app now can stay background by press Home key.(I have tried 1.5 days still can press Home back to application)

-(void)applicationDidEnterBackground
{  
   
    UIApplication *app = [UIApplication sharedApplication];  
   
    UIBackgroundTaskIdentifier taskID;  
    taskID = [app beginBackgroundTaskWithExpirationHandler:^{  
        [app endBackgroundTask:taskID];  
    }];  
    if (taskID == UIBackgroundTaskInvalid) {  
        return;  
    }  

    [NSThread sleepForTimeInterval:5];  
    [app endBackgroundTask:taskID];  
}

沒有留言:

張貼留言