Location API (LocationException timed out issue) on blackberry 9000
Please Login to Remove!
Hi all,
i am working on Location API on Blackberry 9000, when i run the following program i am getting the below exception
javax.microedition.location.LocationException:Time d out while waiting for GPS Location.
Does it require carrier support,i am using Airtel carrier in India. i am getting same exception when i run it on a J2ME device.
Please give me any suggestions on this issue?
package com.ea.location;
import net.rim.device.api.ui.UiApplication;
import net.rim.device.api.ui.container.MainScreen;
import net.rim.device.api.ui.component.RichTextField;
import javax.microedition.location.Location;
import javax.microedition.location.LocationProvider;
import javax.microedition.location.Criteria;
import javax.microedition.location.Coordinates;
import javax.microedition.location.LocationException;
import java.lang.System;
public class BBLocationApp extends UiApplication {
public BBLocationApp(){
UiScreen us = new UiScreen();
pushScreen(us);
}
public static void main(String str[]){
BBLocationApp app = new BBLocationApp();
app.enterEventDispatcher();
}
}
class UiScreen extends MainScreen{
UiScreen(){
setTitle("Location Finder");
String locationVersion = System.getProperty("microedition.location.version" );
RichTextField rtf = new RichTextField("Location Version : "+locationVersion);
add(rtf);
try {
// Create a Criteria object for defining desired selection criteria
Criteria cr = new Criteria();
// Specify horizontal accuracy of 500 meters, leave other parameters
// at default values.
cr.setHorizontalAccuracy(500);
LocationProvider lp = LocationProvider.getInstance(cr);
// get the location, one minute timeout
Location l=null;
try {
l = lp.getLocation(60);
} catch (InterruptedException e) {
RichTextField exception = new RichTextField("EXC 1 : "+e);
add(exception);
// TODO Auto-generated catch block
e.printStackTrace();
}
if(l != null){
Coordinates c = l.getQualifiedCoordinates();
if (c != null) {
RichTextField altitude = new RichTextField("Altitude : "+c.getAltitude());
RichTextField latitude = new RichTextField("Latitude : "+c.getLatitude());
RichTextField longitude = new RichTextField("Longitude : "+c.getLongitude());
add(altitude);
add(latitude);
add(longitude);
// use coordinate information
}
}
} catch (LocationException e) {
RichTextField exception = new RichTextField("EXC 2 : "+e);
add(exception);
// not able to retrive location information
}
}
}
|