iphone auto lock value? - iphone

Isn't possible to retrieve auto lock value?
Or anyone know how to modify the auto lock time like those existing alarm application?
Thanks.

Yes Jason is right. you can use [application setIdleTimerDisabled:YES]; to stop the autosleep. But there is no way to access the auto lock value.
Regards,
Raxit

You can do it. you need to implement the following methods
- (void)applicationWillResignActive:(UIApplication *)application
This gets called when the phone is locked. In this method I would store the time and then impliment this method on the app delegate.
- (void)applicationDidBecomeActive:(UIApplication *)application
This function will be called when unlocking the phone. Use the time you stored when locking the time to determine how long it has been.
You can use this two methods for custom implementation of auto lock interval.

Related

Application keeps closing in background mode

I have a serious problem in my iphone application. It gets closed after entering in background mode (incoming call or even home button press)...I have inserted UIApplicationExitOnSuspend on info.plist and made its value false. But same problem exists...
Do you have any suggestions for this issue? I really need the application to be suspended not closed when entering to background mode...
Thanks
See in your Info.plist file that you had selected the Application does not run in background, see this option must not be selected, if this option is selected means then remove that option from your Info.plist file, this will surely work I think and I hope this will help you
And Implement these Callback function
-(void)applicationDidEnterBackground:(UIApplication *)application;
-(void)applicationWillEnterForeground:(UIApplication *)application;
in your App delegate
If this application was made from old templates of Xcode 3.x, than it probably don't have methods which used by system to check whether your app handle transitions to/from background or not.
Make sure what this methods implemented by your application delegate:
-(void)applicationWillResignActive:(UIApplication *)application;
-(void)applicationDidEnterBackground:(UIApplication *)application;
-(void)applicationWillEnterForeground:(UIApplication *)application;
-(void)applicationDidBecomeActive:(UIApplication *)application;

How to handle phone call interrupts in iPhones below iOS 4

In one of my application I need to handle call interrupt. I know application will directly enter background in iOS 4 onwards. How can I handle this situation devices with iOS's less than 4. Do I need to implement any delegate method to be get notified that a call interrupt has come. Please help.
Thanks in advance.. :)
Use the below Appdelegate method:
(void)applicationWillResignActive:(UIApplication *)application
This delegate will call when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or when the user quits the application and it begins the transition to the background state.
To Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface. For this use the below appDelegate
(void)applicationDidBecomeActive:(UIApplication *)application
You can have a look at The Application Life Cycle. You will find there the difference between iOS 4.0 and earlier versions.

What is the api for Calling Home Screen on iPhone

I want to trigger an event when pressing the home button. Is there any particular api for using that?
Thanks
Shawn
Use applicationWillResignActive and/or applicationWillTerminate. You have a limited amount of time to do stuff in these functions, so be quick.
Make your viewController a NSApplication delegate and the implement
- (void) applicationDidEnterBackground:(UIApplication *)application

iPhone Application Themes

I tried using a multi-value settings bundle to change the view. I would do the if statements in the applicationdidfinishloading in the application delegate. Apparently the method isn't called every time the app is loaded, and it would not work correctly.
If anyone has done this, or has any suggestions, links to tutorials. I would really appreciate it. I'm just trying to load views (nibs) based on user preference.
I think you can put your code in
- (void)applicationDidBecomeActive:(UIApplication *)application
or
- (void)applicationWillEnterForeground:(UIApplication *)application
methods also because from iOS 4.0 due to multitasking your app is just in the background state so it wont call applicationdidfinishloading method when the user presses the icon of your app again.

Retain the State of iPhone Application after exit

How can I retain the state of an iPhone after it has exited. What is the easy way to do it?
The first question is when do you save? The answer is in two places (assuming you want to support 3.x and 4.x devices).
First, for OS 3.x devices (and OS 4 devices that don't multi-task):
- (void)applicationWillTerminate:(UIApplication *)application
And second, for OS 4.x devices:
- (void)applicationDidEnterBackground:(UIApplication *)application
You need to do this on iOS4 devices because if the app is shutdown while it's in the background it is just killed; you never see the applicationWillTerminate message.
As for the how, well it depends on how complex your app is. I created a simple protocol that I implement for each view controller that might want to save its state:
#protocol SaveState
- (NSData*) saveState;
- (id) initWithSaveState:(NSData*)data;
#end
It saves the state by looping through view controllers in the main navigation controller and calling the save state method. It then does the reverse in the applicationDidFinishLaunching: method. More information on my blog.
In your application delegate, you can define the -applicationWillTerminate: method to include code to save application state data.
- (void) applicationWillTerminate:(UIApplication *)application {
// save state to data model here...
}
Your data model is up to you. For example, this could be a set of user defaults or a Core Data store.
The next time the app is started, you could check for saved state data in -applicationDidFinishLaunching: and initialize the app appropriately.
If you are using iOS 4 and your application supports multitasking features, you will get some of the state saving functionality "for free" because the app resigns focus, instead of terminating.