Xamarin.iOS geolocation - xamarin.ios

I have been browsing the web for a couple of hours to find ways to get the device's geolocation but to no avail.
I could find some documentation for android, but nothing for iOS. Anyone has any ideas or can point me to the right direction?

The Xamarin.Mobile component has a cross-platform GeoLocation service. It comes with samples.
Xamarin also has a Core Location sample app.
This question has also been asked and answered on Stack Overflow many times.
CLLocationManger lm = new CLLocationManger();
... (Acurray)
... (Other Specs)
lm.LocationsUpdated += delegate(object sender, CLLocationsUpdatedEventArgs e) {
foreach(CLLocation l in e.Locations) {
Console.WriteLine(l.Coordinate.Latitude.ToString() + ", " +l.Coordinate.Longitude.ToString());
}
};
lm.StartUpdatingLocation();

Related

Can I trigger the Hololens Calibration sequence from inside my application?

I have a hololens app I am creating that requires the best accuracy possible for hologram placement. This application will be used by numerous individuals. Whenever I try to show the application progress, I have to have the user go through the calibration process, otherwise the holograms appear to have way too much drift.
I would like to be able to call the hololens calibration process automatically when the application opens. Later, after I set up user authentication and id management, I will call the calibration process when a new user is found.
https://learn.microsoft.com/en-us/windows/mixed-reality/calibration
I have looked into the calibration (via the above documentation and elsewhere) and it seems that all it is setting is IPD. However the alternative solutions I have found that allow for dynamic ipd adjustment appear to be invalid for UWP Store apps. This makes them unusable for me.
I am looking for any help or direction, or if this is even possible. Thank you.
Yes, it is possible to to this, you need to use the LaunchUriAsync protocol to launch the following URI: ms-hololenssetup://EyeTracking
Here is an example implementation, obtained from the LaunchUri example in MRTK
public void LaunchEyeTracking()
{
#if WINDOWS_UWP
UnityEngine.WSA.Application.InvokeOnUIThread(async () =>
{
bool result = await global::Windows.System.Launcher.LaunchUriAsync(new System.Uri("ms-hololenssetup://EyeTracking"));
if (!result)
{
Debug.LogError("Launching URI failed to launch.");
}
}, false);
#else
Debug.LogError("Launching eye tracking not supported Windows UWP");
#endif
}

Windows.UI.Popups.MessageDialog does not work for Windows 10 IoT

await new Windows.UI.Popups.MessageDialog("Test").ShowAsync();
Has anyone else noticed this? Is there an easy work around ?
I have the some problem and I did't found any trick. I made myself a MessageDialog with a and It's not so hard to build it. Try do take a look this http://bitaware.altervista.org/messagedialog-for-iot/
The unique problem is that it do not work across platforms. If you would this behavior you have to get a condition
string platform = AnalyticsInfo.VersionInfo.DeviceFamily;
if (platform == "Windows.IoT")
{
//Your code for IoT
}
else
{
//Your code for other devices
}
I know is not elegant but I think we have no other choice.
I hope it was helpful

Windows 10 Phone app Turn on flash (lamp)

I have a problem. I m a new windows phone 10 developer and i have a problem.
How can i turn on flashlight on a Lumia 930 ? I can t find any answer on internet.
Thx alot,
Regards
The Windows.Devices.Lights.Lamp namespace is where you need to look, there's an example of Lamp usage in Windows 10 https://github.com/Microsoft/Windows-universal-samples/tree/master/lamp that might be of help.
Here's a small example based on this as an alternative to the link:
using (var lamp = await Lamp.GetDefaultAsync())
{
lamp.BrightnessLevel = 1.0F;
lamp.IsEnabled = true;
}

Best approach for playing a single tone audio file?

Can anyone tell me the best approach to playing single-tone, audio (.mp3) files in a Windows Phone 8 app? Think of a piano app, where each key would represent a button, and each button would play a different tone.
I'm looking for the most efficient way to go about this - I've got 8 different buttons that need to play a different tone when tapped.
I tried using the MediaElement:
MediaElement me;
public MainPage()
{
InitializeComponent();
me = new MediaElement();
me.AutoPlay = false;
me.Source = new Uri("/Sounds/Sound1.mp3", UriKind.Relative);
btnPlay.Click += btnPlay_Click;
}
private void btnPlay_Click(object sender, EventArgs e)
{
me.Play();
}
But nothing happens, either in the emulator or on a device (testing w/ a Lumia 822). Am I doing something wrong here? It seems like it should be pretty simple. Or would using MediaElement even be the best thing to use for my scenario?
Would this fall under the Background Audio category? I've read through this example but it seems overkill for what I want to do.
I've also read about using XNA's SoundEffect to do the job, but then I'd have to convert my .mp3 files to .wav (which isn't necessarily a problem, but I'd rather not go through that if I don't need to).
Can anyone tell me either what I'm doing wrong in my example above or guide me to a better solution for playing quick <1s audio tones?
I had this problem before with MediaElement not playing audio files. After many attempts I found out that it only plays if it defined in the xaml and AutoPlay is set to true.
Try defining it in the xaml or you can just add it to your LayoutRoot.
var me = new MediaElement();
LayoutRoot.Children.Add(me);
me.AutoPlay = true;
me.Source = new Uri("Sound/1.mp3", UriKind.Relative);
I have had good luck just doing this piece of code in my app. But it may not work as well in your context, give it a whirl though.
mediaElement.Source = new Uri("/Audio/" + songID.ToString() + ".mp3", UriKind.Relative);
mediaElement.Play();

For testing GPS based J2ME app, Is there any emulator which have built in GPS?

I am new in J2ME app development field. I am developing GPS based app using Nokia Maps for series 40 mobiles. I want such emulator which provide GPS(to retrieve & set current coordinates & many other purposes). I search a lot on google but I didn't found such emulator.... even what ever emulators provide by Nokia SDKs; they also don't have GPS capability... Then how should I get such emulator??
You can download the latest Nokia IDE (which includes the Nokia Maps Plugin) here:
Emulator download
The emulator associated with the SDK includes tools to simulate JSR-179 location calls (e.g. Cell-Id/GPS), you can play back coordinates for a saved file and receive them at regular intervals. Look at the emulator's Tools > Route Editor menu.
The confusion here is the difference between GPS positioning and Cell-Id positioning. There are currently no series 40 mobiles (that I know of) with a GPS unit - hence positioning will need to be done by Cell-ID - In this case the only way to retrieve frequent location updates in the Cell-ID scenario is to call the getLocation() method within a repeating loop. Retrieving location objects via the locationUpdated() method, can only be done in a GPS-based location retrieval.
In summary you can get a location from any Java ME phone supporting JSR-179, you won't be using GPS though.
To get a location use the following:
cellIdLocator = getCellIdProvider();
cellIdLocator.getLocation(DEFAULT_TIMEOUT);
Where the cell-id provider can be held in a singleton
private LocationProvider cellIdLocator;
public LocationProvider getCellIdProvider() throws LocationException {
if (cellIdLocator == null) {
int[] methods = {
Location.MTA_ASSISTED | Location.MTE_CELLID
| Location.MTY_NETWORKBASED};
cellIdLocator = LocationUtil.getLocationProvider(methods, null);
}
return cellIdLocator;
}

Resources