In the normal activities when you don't use your iPhone for a while it goes sleep and then it goes in the standby mode to avoid the draining of the batteries. Sometimes you could have the need to take your iPhone up without stimulating it. In this case you can use the UIApplication class, it is very simple to use this class to do the job. Simply add the following line in your AppDelegate source
I've added this line in the didFinishLaunchingWithOptions method
– (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
// Override point for customization after application launch.
// Add the main view controller's view to the window and display.
self.window.rootViewController = self.mainViewController;
Somewhere in the internet I've found the following call
[[UIApplication sharedApplication] setIdleTimerDisabled:YES];
that also do the job fine. But I couldn't find the references in the official documentation of Xcode 4.0. Each search for setIdleTimerDisabled has been redirected to the idleTimerDisabled property of the UIApplication Class.
IMHO an application that uses the setIdleTimerDisabled could be rejected from the AppStore.
This property is available since iOS 2.0
Anyway if you want to use this property you should take care of the following warning from the official documentation:
Important: You should set this property only if necessary and should be sure to reset it to NO when the need no longer exists. Most applications should let the system turn off the screen when the idle timer elapses. This includes audio applications. With appropriate use of Audio Session Services, playback and recording proceed uninterrupted when the screen turns off. The only applications that should disable the idle timer are mapping applications, games, or similar programs with sporadic user interaction.