MonoTouch - supporting iPhone/iPod Touch/iOS Version 4 - More Wally - Wallace B. McClure
in

MoreWally.com

Giving people what they want, More Wally. This is the technical and personal blog site of
Wallace B. (Wally) McClure.

This Blog

Syndication

News

Please goy buy 3-4 copies of my book on MonoTouch titled "Professional Android Programming with Mono for Android for .NET/C# Developers." They make great gifts all year round. Plus, I get about $.25 when you buy a copy.

Technical Sites

More Wally - Wallace B. McClure

This blog will have all kinds of posts about Wally McClure. In it, there will be tons of .NET and computer programming posts as well as Wally's views on life in general. As you might guess, this site and blog help you get More Wally in your life. What more could anyone want? iPhone, Android, MonoTouch, MonoDroid, Mobile, HTML5, .NET, ADO.NET, ASP.NET, AJAX, jQuery, jQuery Mobile, ASP.NET AJAX, and Windows Azure............follow me on twitter at Wally

MonoTouch - supporting iPhone/iPod Touch/iOS Version 4

You may have been hearing about the iOS Version 4 a lot.  You probably have installed it onto your iPhone/iPod Touch devices.  It's got a couple of cool features that I think are significant.  One is the ability to run applications in the background.  Now, this isn't general purprose in the background as I understand it.  Its for very specific situations.  In my specific situation, I wanted to check the location of a phone and call a method when it's location changed (no, I'm not stalking you).  Anyway, it looks like there are two steps in the process. 

Step on in the process is for the application to tell the device that the app needs to recieve background updates.  This is done through the Info.plist file.  You will need to modify your file to look like this:

Info.plist

Notice the UIBackgroundModes entry.  I added an entry for location.  The three possible entries are:

  • audio.
  • location.
  • voip.

I think that they are all fairly self explanatory.

The next step is to run some code to listen for events in the background.  My code to do this is:

            cllm = new CLLocationManager();
            cllm.DesiredAccuracy = 1000;
            cllm.StartMonitoringSignificantLocationChanges();
            cllm.StartUpdatingHeading();
            cllm.StartUpdatingLocation();
            cllm.UpdatedLocation += HandleCllmUpdatedLocation; // an event to handle changes
 

and that seems to be it.  I'm getting device updates in the bacground.  Life seems to be pretty good on this.  FYI, you might need to set your values differently, but this should get the point across.

Comments

 

Twitter Trackbacks for MonoTouch - supporting iPhone/iPod Touch/iOS Version 4 - More Wally - Wallace B. McClure [morewally.com] on Topsy.com said:

Pingback from  Twitter Trackbacks for                 MonoTouch - supporting iPhone/iPod Touch/iOS Version 4 - More Wally - Wallace B. McClure         [morewally.com]        on Topsy.com

August 31, 2010 1:55 PM
2006 - Wallace B. McClure
Powered by Community Server (Non-Commercial Edition), by Telligent Systems