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

How to Incorporate Location into Your BlackBerry Applications

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



Before we delve in any further into this article, I am going to assume that you are already familiar with programming basic BlackBerry applications, and that you have the required development environments and simulators installed on your computer. If not, I suggest taking a peek at BlackBerry's Developer Zone to get up to speed.

GPS Information and the BlackBerry

Not all BlackBerry devices support GPS (Global Positioning System) technology, but on the ones that do, applications exist that allow the user to display their current position on a map in real time. In addition, applications can supply directions, both textual and image-driven, and suggest alternate routes. They can even give the user satellite and street level imagery. To achieve these wonders, BlackBerry applications rely on the Location API for Java Platform (JSR 179). We will be working with this JSR throughout the remainder of this article.

For starters, we will look at methods and modes used to obtain local GPS information. There are three Location modes available to use. The first is cell site, which lets us retrieve information from cell site towers and the strength of the user's signal. Of all the location modes, this method is the fastest, but be forewarned - that speed comes with a disadvantage: the accuracy is sub-par and you cannot obtain speed or routing information. Note that cell site support depends on the carrier.

To get location information using the cell site mode, create a new Criteria object, like so:

Criteria criteria = new Criteria():

Next you will need to Invoke the following:

criteria.setHorizontalAccuracy(NO_REQUIREMENT); //this tells the program that there is no requirement for longitude accuracy

criteria.setVerticalAccuracy(NO_REQUIREMENT); //the same as above, but with regards to latitude

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

setPreferredPowerConsumption(POWER_USAGE_LOW); //set the power consumption to low

After this you will need to invoke LocationProvider.getInstance(), which in turn stores the information in a LocationProvider object. To do so, type in the following:

LocationProvider provider = LocationProvider.getInstance(criteria);

>>> 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: