Home arrow Smartphone Development arrow Page 2 - How to Incorporate Location into Your BlackBerry Applications

Getting Information via PDE - Smartphone Development

If you have ever been in an unfamiliar place or stuck in traffic and looking for an alternate route, then you already know the magic that is GPS. One of the hottest areas in smartphone development today is location-based services, and BlackBerry is on the cutting edge when it comes to providing those services. In this article we will discuss BlackBerry’s support of JSR 179, and learn to incorporate GPS functionality into our applications.

  1. How to Incorporate Location into Your BlackBerry Applications
  2. Getting Information via PDE
  3. Display Our Data
  4. Creating the Location Document
By: James Payne
Rating: starstarstarstarstar / 1
August 20, 2009

print this article



The second location mode we can use to retrieve data is the assisted mode. This mode obtains information via satellites with a Position Determination Entity, or PDE. The up side to this method is that it is more accurate than the cell site mode, and faster than the third method (autonomous). The down side is that it is not as accurate as the autonomous method, except in a few rare situations.

To get the location using the assisted mode, create a new Criteria object, in the following manner:

Criteria criteria = new Criteria():

Next you will want to Invoke the following:

criteria.setHorizontalAccuracy(100); //indicates that there is a requirement for horizontal accuracy

criteria.setVerticalAccuracy(NO_REQUIREMENT); //indicates that there is no accuracy required for latitude

criteria.setCostAllowed(true); //indicates that the cell site mode can result in a fee

criteria.setPreferredPowerConsumption(POWER_USAGE_MEDIUM) //tells the program that there is a medium power usage requirement

The last thing to do is to Invoke LocationProvider.getInstance(), which stores the information in a LocationProvider object:

LocationProvider provider = LocationProvider.getInstance(criteria);

Getting Information with GPS

The last location mode is known as autonomous, as referenced above. This information is retrieved from a GPS receiver on the BlackBerry device and does not rely on a wireless network. It provides the best accuracy for location, but unfortunately is slower than the other methods in terms of time-to-first-fix.

If we wish to get accurate information, we do as before -- create an instance of a Criteria object, using the same method as before:

Criteria criteria = new Criteria():

Then we will Invoke the following, this time changing our requirement:

criteria.setHorizontalAccuracy(50); //indicates that there is a requirement for longitudinal accuracy (this value is optional)

criteria.setVerticalAccuracy(50); //indicates that there is a requirement for latitudinal accuracy (this value is optional)

Note that both of these values require a value in meters.

If we wish to get an approximate value, we do so like this:

criteria.setHorizontalAccuracy(NO_REQUIREMENT); // that there is no accuracy required for longitude

criteria.setVerticalAccuracy(NO_REQUIREMENT); // that there is no accuracy required for latitude

Next we will deny fees:


And finally, we need to create a LocationProvider object based on these criteria:

LocationProvider provider = LocationProvider.getInstance(criteria);

There are a few other methods for retrieving and storing location information; we will touch upon those in a later article. For now though, let's move on and learn to actually display the data.

>>> More Smartphone Development Articles          >>> More By James Payne

blog comments powered by Disqus
escort Bursa Bursa escort Antalya eskort


- Is Facebook Working on a Branded Smartphone?
- Apple iOS 6 Packed With Features
- Finally, Ubuntu OS for Smartphones?
- App Developers Offer Thoughts on Windows Pho...
- App Promo Survey Displays Developer Struggles
- Apptopia Market Helps Developers Recoup Inve...
- Is Fragmentation a Plus for App Developers?
- Juniper Networks: Android App Malware Increa...
- Developer's Losing Interest in Android?
- Android Developers Pushed Towards Google Wal...
- Google Increases Android App Size Limit
- ATandT To Charge App Developers, Android Lac...
- Android Slipping in App War versus Apple
- Apple and Google Battle to Clean Up App Mark...
- iOS Development: Hello World! in Xcode Part 2

Developer Shed Affiliates


Dev Shed Tutorial Topics: