topical media & game development
#mobile-application-12-MonoTouchOther-MonoTouchOther-AppDelegate.cs / cs
using System;
using System.Collections.Generic;
using System.Linq;
using MonoTouch.Foundation;
using MonoTouch.UIKit;
using MonoTouch.CoreLocation;
namespace MonoTouchOther
{
[Register ("AppDelegate")]
public partial class AppDelegate : UIApplicationDelegate
{
// class-level declarations
UIWindow window;
MonoTouchOtherViewController viewController;
//
// This method is invoked when the application has loaded and is ready to run. In this
// method you should instantiate the window, load the UI into it and then make the window
// visible.
//
// You have 17 seconds to return from this method, or iOS will terminate your application.
//
public override bool FinishedLaunching (UIApplication app, NSDictionary options)
{
window = new UIWindow (UIScreen.MainScreen.Bounds);
viewController = new MonoTouchOtherViewController ();
window.RootViewController = viewController;
window.MakeKeyAndVisible ();
CLLocationManager locationManager = new CLLocationManager ();;
locationManager.Delegate = new LocationDelegate ();
locationManager.StartUpdatingLocation ();
locationManager.StartUpdatingHeading ();
return true;
}
private void pList()
{
var plist = NSUserDefaults.StandardUserDefaults;
// get settings
string stringSetting = plist.StringForKey("StringSetting");
int intSetting = plist.IntForKey("myIntKey");
bool boolSetting = plist.BoolForKey("myBoolKey");
// save settings
plist.SetString("string", "StringSetting");
plist.SetInt(1, "IntSetting");
plist.SetBool(true, "BoolSetting");
plist.Synchronize();
}
}
public class LocationDelegate : CLLocationManagerDelegate
{
public LocationDelegate () : base()
{
}
public override void UpdatedLocation (CLLocationManager manager, CLLocation newLocation, CLLocation oldLocation)
{
Console.WriteLine(newLocation.Altitude.ToString () + "meters");
Console.WriteLine(newLocation.Coordinate.Longitude.ToString () + "º");
Console.WriteLine(newLocation.Coordinate.Latitude.ToString () + "º");
Console.WriteLine(newLocation.Course.ToString () + "º");
Console.WriteLine(newLocation.Speed.ToString () + "meters/s");
}
}
}
(C) Æliens
04/09/2009
You may not copy or print any of this material without explicit permission of the author or the publisher.
In case of other copyright issues, contact the author.