Monday, May 21, 2012

Application is not entering in Background?

Recently I was working on an application and I face a problem. When I press home button iphone shows dashboard and I felt that application is in background. But it was a total mess when I again tried to bring app in foreground.. Oooopppssss…. its a black screen with status bar with some what transparency..

I tried to put debug point to my  application's AppDelegate class and see whether application is entering in background and wooooohhhh applicationWillResignActive and applicationDidEnterBackground are not being called.

I was wondering why this abnormal behavior with UIApplicationDelegate. Then I tried to go in depth. With lots of goggling and forums I didn't got why this is happening.

Finally I discovered the solution. If you have some thing running on your main thread until it get finish application will not enter in background. Can you believe it? Than I tried to perform my process on a separate thread and application is entering in background by calling my both of methods and when I bring the app back in foreground it works. Phew…

Conclusion: If you have some lengthy process running on main thread and user enters in background and before than your application is still running and not actually in background. Application will enter in background while your main thread complete that process. So for avoiding this kind of issue try to perform your lengthy processes in background.

Hope this will help someone for sure…

Cheers :)

Thursday, May 17, 2012

Game Programming Related

Localization Related

Location Related

  1. How to find altitude value programmatically when your device connected to wifi ?
Ans:  When you are connected to wifi, you will not be able to get altitude value, using corelocation framework methods. it will return value 0. Even you will connected to gps, its not always sure that you will get altitude value.

So how to get altitude value ???
we searched a bit and found, "Google Elevation API" which helps you to find altitude value based on location.

Here is an Example: