Discussion Board

Results 1 to 2 of 2
  1. #1
    Registered User
    Join Date
    Feb 2012

    LocationException In J2me app

    I have written an application for a nos-gps phone to get location information. I am testing this app. on c2-02 as told on this forum. The code is as follows-
    import com.nokia.mid.location.LocationUtil;
    import javax.microedition.lcdui.Command;
    import javax.microedition.lcdui.CommandListener;
    import javax.microedition.lcdui.Display;
    import javax.microedition.lcdui.Displayable;
    import javax.microedition.midlet.MIDlet;
    import javax.microedition.midlet.MIDletStateChangeException;
    import javax.microedition.lcdui.Form;
    import javax.microedition.location.LocationProvider;
    import javax.microedition.location.Location;
    import javax.microedition.location.LocationException;
    import javax.microedition.location.QualifiedCoordinates;
    public class GetCellIdCoordinates extends MIDlet implements Runnable, CommandListener
    { LocationProvider provider;
    Location location;
    QualifiedCoordinates coordinates;
    Thread t;
    Form f;
    Display display;
    Command exitCommand=new Command("Exit", Command.EXIT,0);
    protected void startApp() throws MIDletStateChangeException
    { display = Display.getDisplay(this);
    f=new Form("Current Location!");
    f.append("Getting current location by using Cell ID...");
    t=new Thread(this);
    protected void destroyApp(boolean unconditional) throws MIDletStateChangeException
    { }
    protected void pauseApp() { }
    public void run()
    try {
    //Specify the retrieval method to Online/Cell-ID
    int[] methods = {(Location.MTA_ASSISTED | Location.MTE_CELLID | Location.MTE_SHORTRANGE | Location.MTY_NETWORKBASED)};
    // Retrieve the location provider
    provider = LocationUtil.getLocationProvider(methods, null);
    catch (NoClassDefFoundError ex)
    { f.deleteAll();
    f.append("Cell-ID retrieval not supported on this device");
    catch(InterruptedException e)
    { f.deleteAll();
    f.append("Location retrieval was interrupted");
    catch(LocationException x)
    { f.deleteAll();
    f.append("Location could not be retreived"); }
    public void commandAction(Command c, Displayable d)
    { if(c==exitCommand)
    { try {
    catch (MIDletStateChangeException ex)
    { }


    First I tested the application on c2-01 & then I came to know that c2-01 does not support this method. Then I tried the same on c2-02 it is giving LocationException. In some threads on this forum I have read that when provider does not provide location information such exception occurs. But I have tested another location app on the same provider with a setting GPS off & network provider on.

    Can anybody tell why am I getting this error ?

  2. #2
    Super Contributor
    Join Date
    Nov 2003
    Bangalore , India

    Re: LocationException In J2me app

    I hope you are using the same code as mentioned here http://www.developer.nokia.com/Commu...on_via_Cell_ID

    Also hope you have a SIM card in the device and its active and have GPRS active and configured for Java apps ?


Similar Threads

  1. Text Field Focus Problem with J2me(j2me Polish)
    By pollux.java in forum Mobile Java Networking & Messaging & Security
    Replies: 2
    Last Post: 2010-10-20, 06:25
  2. J2ME Polish or LWUIT or what for commercial J2ME software?
    By SebastianM in forum Mobile Java General
    Replies: 10
    Last Post: 2010-08-18, 13:04
  3. How to use J2ME polish code in existing J2ME app.
    By raselbd in forum Mobile Java General
    Replies: 2
    Last Post: 2008-08-26, 14:30
  4. How to sign midlet in j2me using Operator or Manufacturer in j2me
    By bfchaudharimca in forum Mobile Java General
    Replies: 2
    Last Post: 2008-08-15, 15:25
  5. Compiling J2ME code with J2ME polish
    By tharindufit in forum Mobile Java General
    Replies: 3
    Last Post: 2008-06-05, 13:51

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts