java.lang.InterruptedException While Trying to Get Location - blackberry

Here is my code:
Criteria criteria = new Criteria();
LocationProvider locationProvider = LocationProvider.getInstance(criteria);
Location currentLocation = locationProvider.getLocation(300);
It throws the exception at the third line. How can I fix this?

Do you run your application in the simulator? If yes ,then you have to change the IT policy.
Go to Simulate select Set IT Policy & GPS Location as given below.
I hope this will help you.. :)

I figured it out. When I am in a closed area GPS cannot receive data and throws InterruptedException.

Related

Trying to set Estimote iBeacon GPIO pin .high - SWIFT iOS

Ive been trying for a few days now to set a pin high (Estimote location beacon) from an app I'm building.
Im doing something wrong as i am getting an error when the block fires off. Error is: [ESTTelemetryInfo portsData]: unrecognized selector sent to instance...
Ive looked everywhere for a snippet but can't find anything. I only want to be able to set the pin high (i don't need to send any data). If i can set the pin high i figure i could set it low when done using the same methods. This is the code:
let telem = ESTTelemetryInfo.init(shortIdentifier: "xxxxxxxxxxxxxxxx")!
let setPinHigh = ESTTelemetryNotificationGPIO.init(notificationBlock: { (telemInfo) in
if telInfo.shortIdentifier! != "xxxxxxxxxxxxxxxx" { return }
telemInfo.portsData.setPort(.port0, value: .high)
})
setPinHigh.fireNotificationBlock(with: telem)
Any help would be greatly appreciated.
ps Sorry if this is incorrectly formatted (long time reader first time poster).
Cheers
Gary
Fixed..we'll sort of. For anyone wanting to know the right way to to set a pin high, in output mode, is to connect to the beacon first through the device manager: ESTDeviceManager() -set the delegate in the class as ESTDeviceManagerDelegate - startDeviceDiscovery(with: deviceFilter) then in the delegate method:
func estDeviceConnectDidSucceed(_ device: ESTDeviceConnectable) { self.settings.gpio.portsData.setPort(.port0, value: .high)
}
BUT -> at the moment there is a bug that portsData has no member 'setPort'. I've filed a bug issue with Estimote on GitHub. Will come back to report once it's fixed.

Unable to set CEMarker's collisionPriority

I'm trying to "mimic" the BusinessLayer functionality by creating a CEMarkerGroup for my own markers, then setting the following:
CEMarkerGroup *myGroup = [self.mapView markerGroupWithName:#"myMarkers"];
[myGroup setShouldTestForCollisions:YES];
And then, according to the Citymaps' current documentation, I try to set individual collisionPriority values to each like this:
[marker setCollisionPriority:25.0f]; //<-- ERROR!!, or
marker.collisionPriority = 25.0f; //<-- same ERROR
[myGroup addMarker:marker];
Error is: No visible #interface for 'CEMarker' declares the selector 'setCollisionPriority:'
As my goal is to approximate Citymaps' very slick behavior of avoiding marker overlaps, does anyone know of a workaround for this issue, or perhaps another approach altogether? Much thanks!
I am a developer at Citymaps. Thank you for your interest in our SDK!
Our documentation got a bit ahead of itself. Turns out, we never exposed the collisionPriority property. I've given myself a ticket to do so, and will let you know immediately when a new build is out containing this change.

swift user's location issue when trying to get current location

I am doing an app wich uses the current user location and of it's friend's agenda.
I wrote a little bit of code which is suppossed to show your location
var loc :CLLocationCoordinate2D = self.mapView.userLocation.coordinate
var region = MKCoordinateRegionMakeWithDistance(loc, 5, 5)
self.mapView.setRegion(region, animated: true)
Furthermore I am getting the error saying :
Trying to start MapKit location updates without prompting for location authorization. Must call -[CLLocationManager requestWhenInUseAuthorization] or -[CLLocationManager requestAlwaysAuthorization] first.
After some research I don't understand what I'm supposed to do to improve my location[i changed from debug->simulateLocation but nothing changed]
Can you please explain what I have to keep in mind and what I need to do to improve my app?
[edit1] Is it possible that the simulator behaves this way and the phone should not behave the same way?
As of iOS 8 you have to explicitly ask the user for permission:
var systemVersion = NSOperatingSystemVersion(majorVersion: 8, minorVersion: 0, patchVersion: 0)
if NSProcessInfo.processInfo().isOperatingSystemAtLeastVersion(systemVersion) {
locationManager.requestAlwaysAuthorization()
}
// get current location
if CLLocationManager.authorizationStatus() == CLAuthorizationStatus.Authorized {
locationManager.startUpdatingLocation()
}
Furthermore you have to explicitly declare the permission question in your Info.plist
NSLocationAlwaysUsageDescription
I figured this issue out by google-ing it a little bit:
http://rshankar.com/get-your-current-address-in-swift/
One of the steps is going to settings->General->...Use Location->Always,This is suppossed to solve it and you will not get that error.
Furthermore the person that made the tutorial mentioned that you should enter a location just ot be sure it works and VOILA!

WinRT Geolocator always return the same position

We have a strange behavior with the WinRT Geolocator in one of our app. The user clicks on a button in the app to get the current position. Works fine the first time but all subsequent click on the button returns the same coordinates even tough we move for more than one kilometer.
The application runs on a ThinkPad and we've installed an application called "GPS Satellite" and if we switch to this application, get a coordinates, and return to our app then the Geolocator returns the correct coordinates. So we know the GPS is working fine, but seems like the coordinates are kept in cache even tough we've set a expiration of a few millisecond.
private async void ExecuteObtenirCoordGPSCommand()
{
try
{
Geolocator geolocator = new Geolocator();
geolocator.DesiredAccuracy = PositionAccuracy.High;
// Make the request for the current position
Geoposition pos = await geolocator.GetGeopositionAsync(new TimeSpan(0,0,0,0,200), new TimeSpan(0,0,5));
Place.Latitude = pos.Coordinate.Latitude;
Place.Longitude = pos.Coordinate.Longitude;
}
catch
{
GPSMsgErreur = "The GPS is unavailable";
}
}
We've tried to put a expiration on the method GetGeopositionAsync but it didn't solved the problem.
We've tried to put the Geolocator var at the class level with the same result.
Any ideas?
Not sure if this is your issue but the API you are using is tagged has obsolete in this post:
http://msdn.microsoft.com/en-us/library/windows/apps/windows.devices.geolocation.geocoordinate
Try using:
Place.Latitude = pos.Coordinate.Point.Position.Latitude;
Place.Longitude = pos.Coordinate.Point.Position.Longitude;
You may also use:
double someVar = pos.Coordinate.Accuracy
to figure out what is the margin of error on the device. May be you where not far enough from your first location and your second location was within the margin of error...
I can also tell you that I have a software built with Visual Studio 2013 Windows (WinRT) that runs on a ThinkPad using the same objects you are using and it works fine.
The main difference between mine and yours is that I am using the API showed above and that I did not use the following statement:
geolocator.DesiredAccuracy = PositionAccuracy.High;
And that I did not pass any parameters to the GetGeopositionAsync method.
I hope this helps.
Cheers, Hans.

Get Location with Mvvmcross

I'm trying to get location in my application (mvvmcross/monodroid)
I follow this post : http://slodge.blogspot.be/2012/04/getting-location-information-in.html
I'm using Vnext version.
When I try to get location I have this message in output : "Location Service Provider unavailable - returned null".
I have this code to initialise location plugin in App.cs :
protected override void InitialisePlugIns()
{Cirrious.MvvmCross.Plugins.Location.PluginLoader.Instance.EnsureLoaded();}
And in my ViewModel I follow the sample. I have to get location when I'm on the view so I added this code in my ViewModel constructor :
_watcher = this.GetService<IMvxGeoLocationWatcher>();
DoStartStop();
I did somthing wrong I have this message ?
edit: I use Samsung Galaxy Tab 2.0 7"
I'm not sure what the problem might be, but some things to try are:
does your device definitely have gps? And is it enabled?
does your test app have coarse and fine capabilities declared in the manifest file?
does another app work? Eg the mvx tutorial app with its location view?

Resources