Blackberry Location issue - blackberry

My application uses gps location, but the request fails (time out error) every time if I stay inside of the building but location gets refresh well when I refresh the location from device Location Settings option if I stay in building too.
Here is my code
Criteria myCriteria = new Criteria();
myCriteria.setCostAllowed(false);
LocationProvider myLocationProvider = LocationProvider.getInstance(myCriteria);
Location myLocation = myLocationProvider.getLocation(((int)timeOutInMiliseconds/1000));
lastLatitude = myLocation.getQualifiedCoordinates().getLatitude();
lastLongitude = myLocation.getQualifiedCoordinates().getLongitude();
lastAltitude = myLocation.getQualifiedCoordinates().getAltitude();
lastAccuracy = myLocation.getQualifiedCoordinates().getHorizontalAccuracy();
lastSpeed = myLocation.getSpeed();
Please advise.
Ali

When you set the cost setting to false (myCriteria.setCostAllowed(false);), you set the GPS mode to be autonomous (the below table was taken from Location based services development guide - Criteria mapping properties.
Autonomous mode relies on GPS satellites only (see more about GPS modes here).
This mode uses the GPS receiver on the BlackBerry device to retrieve location information. This mode cannot be used indoors or in close proximity to many physical obstructions, and it can take several minutes to fully synchronize with four or more satellites for the first GPS fix.
That's the reason why your request fails. Try using other GPS modes: assisted or cellsite.
Assisted mode
Assisted mode relies on GPS satellites and servers on the wireless network. This mode uses the wireless network to retrieve satellite information. This mode can achieve a fast retrieval of the first GPS fix.
For assisted mode use this snippet (it is worth noting that there are several assisted modes):
Criteria myCriteria = new Criteria();
myCriteria.setPreferredPowerConsumption(Criteria.POWER_USAGE_MEDIUM);
myCriteria.setHorizontalAccuracy(100);
myCriteria.setVerticalAccuracy(100);
myCriteria.setCostAllowed(true);
Cellsite mode
Cellsite mode relies on the geolocation service, or the wireless network to provide the location information of the current base station. This mode uses the wireless network to achieve the first GPS fix, and is generally considered the fastest mode. This mode does not provide BlackBerry device tracking information such as the speed and the bearing.
For cellsite mode use this snippet:
Criteria myCriteria = new Criteria();
myCriteria.setPreferredPowerConsumption(Criteria.POWER_USAGE_LOW);
myCriteria.setHorizontalAccuracy(Criteria.NO_REQUIREMENT);
myCriteria.setVerticalAccuracy(Criteria.NO_REQUIREMENT);
myCriteria.setCostAllowed(true);

Related

Significant-Change Location Service will use Wi-Fi or Mobile Data?

When use Significant-Change Location Service it must use Wi-fi ? Without Wi-fi this service will work or not?
Theoretically it should work but location mechanism is a bit complicated in iOS.
iOS devices uses a system called aGPS. Which relies on combination of gps, cellular, wi-fi, geofencing etc. Wi-fi is the fastest location update option for the location manager since you can get your accurate-enough information immediately. GPS is the most accurate one but it takes couple of minutes to lock and determine your location if you changed your location a lot since the last lock on.
So maybe you had an impression that when wi-fi is disabled significant change location service doesn't work but actually it does. At least this is the expected behavior.

Detecting whether GPS is available iPad (Internal cellular or External Bluetooth)

Is it possible to actually determine with any degree of certainty whether an iPAD actually has a GPS signal. I can think of three cases
Wifi-Only IPAD
Wifi-Only IPAD with External GPS (such as the DualXGPS)
Cellular IPAD with Internal GPS
Apple documentation mentions:
Some location services require the presence of specific hardware on
the given device. For example, heading information is available only
for devices that contain a hardware compass. This class defines
several methods that you can use to determine which services are
currently available.
Are there specific calls that work specifically with a GPS only such as heading or tracking? I'm assuming perhaps only GPS devices have a heading call because the documentation says:
In iOS, a device with the appropriate hardware may also report heading
information. When the value in the headingAvailable property is YES,
you can use a location manager object to retrieve heading information.
Some previous posts suggested trying to get a lock on a very accurate GPS update
Detect if Device has GPS
How can I tell if an iOS device has a GPS?
but i was hoping for something a little more concrete these methods "feel" wishy-washy - because just because an inaccurate GPS signal would likely look like there is no GPS when the device actually has the capability. Also I would think a wifi device which can "mimic-gps" might also some how pass one of these conditions.
Thanks for any help!
The simplest answer is that you should try to use the GPS at the accuracy you need and see if you get it. And deal with the fact that you might not get this accuracy because the user is in a building, or an urban canyon, or doesn't have GPS hardware, or has turned off location services (although this can be detected).
If you get better than 100m accuracy or if the CLLocation has altitude you almost certainly have GPS hardware (but you have to wait quite some time to get a signal lock on at least 4 satellites to get altitude). If you have a cellular radio connection (see Reachability) then you have GPS hardware (except iPhone1). If you have digital compass capability then you have GPS hardware (except iPhone 3G).
Internal GPS hardware is available on all iPhone and iPad that have cellular radios (except iPhone 1, see wiki chart). If you study that chart it appears that all devices (so far) that have GPS hardware also have digital compass (magnetometer) except iPhone 3G.
Using course (as suggested here) from the CLLocation only works if the device is moving fast enough and the GPS has satellite lock. A better option would be to detect if you have a heading from the compass (magnetometer).
You can use the hardware string to determine device capabilities by hardcoding a table of what hardware has what capabilities (described here). This has to be kept updated (which means an app update) when new devices are introduced. Erica Sadun has categories for UIDevice called Capabilities and Hardware on github that attempts this, but may not be usable in the app store.
None of this will help with external plug-in GPS or external bluetooth GPS devices.
if (location.getHoricontalAccuracy()< 40) {
// for sure GPS
} else {
// no GPS or unusable bad GPS
}
you can also use speed and course, if they are valid, then they are from GPS, because It is the only sensor that can measure speed and course. (magentometer shows the current heading, which works without GPS)

How to get the location provider name in iOS?

In Android whenever you get location object you could call "location.getProvider" on the instance to get value like "wifi". Is there something similar in iOS (CLLocation)?
The Location Awareness Programming Guide says:
The [CoreLocation] framework uses information obtained from the built-in cellular, Wi-Fi, or GPS hardware to triangulate a location fix for the device. It reports that location to your code and, depending on how you configure the service, also provides periodic updates as it receives new or improved data
Having said that, you do not have access to how precisely the CLLocationManager determined your location (other than, if you used significant change, that it probably used cell towers). You theoretically could use Reachability to see if you have Wi-Fi availability, but you have no assurances as to what mix of GPS, cellular, and Wi-Fi it used to get your location (even if you happen to have WiFi connection).
What you do have is horizontalAccuracy, which tells you approximately how accurate the location you received is. From a user's perspective, that's probably a more important piece of information.
There isn't a concept of what system provided you with the location on iOS. What you can do is check what the accuracy of the location is. Based on how precise the location is, you can probably surmise if the location was provided by a GPS signal.
The reason this isn't given is that iOS will provide you with an initial location which won't be very accurate (likely based on geo-ip or cell triangulation) and then update the location with more and more precise coordinates if GPS is available.
If your application requires the accuracy provided by a GPS chip, you can add UIRequiredDeviceCapabilities = gps to your Info.plist.

Current location using wi-fi on BlackBerry Storm 2 (9550)

I want to get the current location using wi-fi on my Storm 2 9550. I have implemented LocationProvider and it is working fine on the simulator after sending lat long manually, but it doesn't work on the device.
GPS is already active on the device but to my knowledge BlackBerry GPS cannot get location without a Network Provider. There is no network provider on the device.

Is it possible to get GPS information in a mobile device through APIs without having any GPRS connectivity?

Is it possible to get GPS information in a mobile device through APIs without having any GPRS connectivity?
Edited
Yes, for example on the Java ME platform or Apple iPhone
Yes; if you are on a device that has GPS hardware in it and software development on the device gives you access to that hardware from your software.
This can be using a built in API for opening a COM port. You then just need to open the port that has the GPS hardware connected to (internal GPS receivers inside the device are often connected to a fixed COM port number) start interpreting the (often) NMEA strings that the GPS receiver is sending out.
Or perhaps the device has more specific GPS related APIs, like the GPS intermediate driver in Windows Mobile 5+ that lets the OS talk to any GPS receiver (either built in, or connected via cable or bluetooth to a COM port) and lets multiple applications concurrently interact with the GPS data.
P.S.
GPS has nothing to do with GPRS per se. You might have gotten that idea because of A-GPS which uses telecom network information and/or a dataconnection (like GPRS, EDGE, UMTS, WLAN, whatever) to download a small file with information about the location of GPS satellites.
This data will then enable your device shorter GPS aquisition times within the time period that this retrieved data is current - often a couple of days to a week I believe - because it does not just need to see what GPS signals it can receive and make sense of that, but it has a lot of prior knowledge about the GPS constellation that should be in orbit in the part of the sky you can see.
GPRS is a two-way data transmission which enables you to access the iternet while the GPS is just a receiver and as peSHIr already mentioned it has nothing to do with GPRS. GPS receiver receives the signals from multiple satellites and calculates the location from time differences.
Anyway... you need GPRS or any other internet connection only if you want to use any web service for reverse geolocation or you want to use google maps or any other location service. But just for receiving (calculating) the coordinates GPS by itself is enough.

Resources