×

Discussion Board

Results 1 to 7 of 7
  1. #1
    Registered User
    Join Date
    Nov 2007
    Posts
    8

    Unhappy Location application not working when installed on Phone

    Hi

    I am not so good in j2me, and i have some sample code which can extract the information like long and lat,

    This application runs properly on Emualator,but when i instlled this application on my phone its not working.

    Can some please Help me out..

    I am Pasting my code here.please try it once..

    Thanks



    import javax.microedition.midlet.*;

    import javax.microedition.lcdui.*;

    import javax.microedition.location.*;


    public class MyLocation extends MIDlet implements CommandListener
    {

    private Display display;

    private Form form;

    private Command cmdExit, cmdOK;

    private StringItem si;



    public MyLocation()
    {



    display = Display.getDisplay(this);

    form = new Form("Location Api test");
    cmdExit = new Command("Exit", Command.EXIT, 5);

    cmdOK = new Command("OK", Command.OK, 1);

    si = new StringItem("Geo Location", "Click OK");

    form.append(si);

    form.addCommand(cmdOK);
    form.addCommand(cmdExit);

    form.setCommandListener(this);


    }



    public void startApp()
    {

    display.setCurrent(form);

    }





    public void pauseApp()
    {



    }



    public void destroyApp(boolean flag)
    {

    notifyDestroyed();

    }



    public void commandAction(Command c, Displayable d)
    {

    if (c == cmdOK)
    {

    Retriever ret = new Retriever(this);

    ret.start();



    }
    else if (c == cmdExit)
    {

    destroyApp(false);

    }

    }



    public void displayString(String string)
    {

    si.setText(string);

    }

    }



    class Retriever extends Thread
    {



    private MyLocation midlet;



    public Retriever(MyLocation midlet)
    {

    this.midlet = midlet;


    }



    public void run()
    {




    try
    {

    checkLocation();

    }
    catch (Exception ex)
    {

    ex.printStackTrace();

    midlet.displayString(ex.toString());

    }

    }



    public void checkLocation() throws Exception
    {

    String string;

    Location l;

    LocationProvider lp;

    Coordinates c;



    Criteria cr = new Criteria();

    cr.setHorizontalAccuracy(500);




    lp = LocationProvider.getInstance(cr);



    // Request the location, setting a one-minute timeout

    l = lp.getLocation(60);

    c = l.getQualifiedCoordinates();
    if (c != null)
    {

    // Use coordinate information

    double lat = c.getLatitude();

    double lon = c.getLongitude();

    string = "\nLatitude : " + lat + "\nLongitude : " + lon;



    }
    else
    {

    string = "Location API failed";

    }

    midlet.displayString(string);

    }

    }

  2. #2
    Registered User
    Join Date
    Feb 2007
    Location
    Tampere
    Posts
    370

    Re: Location application not working when installed on Phone

    Which phone you are using?
    Regards

    - MVP
    "Dare To Dream" - A.P.J.Kalam

  3. #3
    Registered User
    Join Date
    Nov 2007
    Posts
    8

    Re: Location application not working when installed on Phone

    Hi

    at present i am using Nokia E71, but i also tried this on Nokia N95

    I get two initial screens and than application just freeze.

    Thanks

  4. #4
    Nokia Developer Moderator
    Join Date
    Sep 2004
    Location
    Tampere, Finland
    Posts
    11,359

    Re: Location application not working when installed on Phone

    The application type (e.g. LBS) might have a lot to do with how the application is designed but it has nothing to do with how the writen code works.

    You shoud ask this question on the Java forum where those who knows java can help you spot the problem or teach you how do debug the application.
    -- Lucian

    If you are not yet a DVLUP member it is time to correct that mistake :) Click here to join: http://www.dvlup.com/lucian/Invite

  5. #5
    Registered User
    Join Date
    Nov 2007
    Posts
    8

    Re: Location application not working when installed on Phone

    Hi

    Thanks for your reply,

    I tried to post this in java forum but could not get much help.

    Can any body please provide me any sample code, which can show long and lat.

    Thanks in advance

  6. #6
    Nokia Developer Champion
    Join Date
    Sep 2007
    Posts
    915

    Re: Location application not working when installed on Phone

    Quote Originally Posted by jasmeet05 View Post
    Hi

    at present i am using Nokia E71, but i also tried this on Nokia N95

    I get two initial screens and than application just freeze.

    Thanks
    Sometimes when we are in home. The GPS cannot communicate with satellite so we cannot get location. If you are executing your application inside the home then please try to test it out side environment so you can get proper result. I even face same problem in my N96. Let us know if yet you face any problem.

  7. #7
    Registered User
    Join Date
    Nov 2007
    Posts
    8

    Re: Location application not working when installed on Phone

    Hi

    Thanks For your reply,

    Actually it is working fine ,but only once, than for next time i need to compile and run it again, and later send the jar file to phone to make it work.

    I dont understand whats going wrong

    Can some body please help.

    (i tried using it outdoor but not result)

    Thanks

Similar Threads

  1. Reading SMS from the application that is installed in the mobile phone.
    By amishra in forum Mobile Java Networking & Messaging & Security
    Replies: 2
    Last Post: 2008-08-02, 14:41
  2. BluetoothDemo application not working on phone
    By shruthirs in forum Mobile Java General
    Replies: 3
    Last Post: 2007-03-29, 19:20
  3. Application working on one phone but not the other
    By davidrenstrom in forum Mobile Java General
    Replies: 7
    Last Post: 2006-07-06, 16:33

Posting Permissions

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