×

Discussion Board

Results 1 to 10 of 10

Thread: GPS Positioning

  1. #1
    Registered User
    Join Date
    Dec 2009
    Posts
    42

    GPS Positioning

    Hey guys

    I am trying to build an app that gets the users current GPS coordinates if they have GPS available. I have a simple function that returns a comma separated string lat,lng like this:

    Criteria cr = new Criteria();
    cr.setHorizontalAccuracy(500);

    LocationProvider lp = LocationProvider.getInstance(cr);
    Location loc;

    if (lp.getState()==LocationProvider.AVAILABLE)
    {
    try {
    loc = lp.getLocation(30);
    Coordinates c = loc.getQualifiedCoordinates();

    double lat = c.getLatitude();
    double lng = c.getLongitude();

    ret = lat + "," + lng;

    } catch (InterruptedException ex) {
    ret = "Not available";
    } catch (LocationException ex) {
    ret = "Not available";
    }
    }
    else
    {
    ret = "Not available";
    }

    return ret;

    Thats all good and well, but on my app when I call that function, it asks me if I want to allow the app to use Positioning data, I click yes, and coz I dnt have GPS it times out and says not available. But then it asks me again with the same outcome. And if i click no, it just asks me again. So it gets stuck in a continuous loop of checking.

    Any ideas why it is doing this and how I can check if gps is available or not only 1?

    Thanks for any help or feedback

  2. #2
    Registered User
    Join Date
    Dec 2009
    Posts
    42

    Re: GPS Positioning

    Hey

    Just an update. I now tried the app on a Sony Ericsson K810i that has no GPS and the application doesnt load at all. It just says Application error. I do not even call that method from the loading page of the app and it doesnt open. Any ideas how I can check for GPS without the entire app breaking?

    Thanks

  3. #3
    Nokia Developer Champion
    Join Date
    Apr 2007
    Posts
    2,708

    Re: GPS Positioning

    sure there is a great article about that writen by Graham on the Wiki :

    http://wiki.forum.nokia.com/index.ph...API_in_Java_ME

    it won't only supply you with code but there's also a great explanation on how the JVM works regarding to the classes you call in your midlet... So make sure you read it all, it's pretty handy information !

  4. #4
    Nokia Developer Champion
    Join Date
    Apr 2007
    Posts
    2,708

    Re: GPS Positioning

    sorry forgot about your first couple of questions :P

    anyway are you using the LocationListener interface ? From your code-snippet it look you don,t so you might have a look at this wiki article :

    http://wiki.forum.nokia.com/index.ph...aining_GPS_fix

    Another handy thing about the LocationListener interface is that you will also get updates about the state of the LocationProvider

    Also if it keep bugging you with the questions about granting permission you might want to change the permissions for your application in the application manager of the device and set the positioning permissions to "ask-once"...

  5. #5
    Regular Contributor
    Join Date
    Sep 2008
    Location
    Ahmedabad
    Posts
    254

    Re: GPS Positioning

    Hi,

    You are using LocationListener so it will update the location at defined intervals. If you don't want those confirmations then do as Tiger has said i.e. set your permission setting to Ask-once for Position data. Moreover, you can also unregister the location listener if you no longer need GPS data.

    By the way have you checked whether location API exists in the device. If it exists then proceed with your code otherwise give an alert to the end user that Device not supported.
    Sunil
    Mobile Application Developer

  6. #6
    Nokia Developer Champion
    Join Date
    Apr 2007
    Posts
    2,708

    Re: GPS Positioning

    hhmmm, where do you see he is using Loactionlistener interface ?
    I don't see him using the addLocationListener() method anywhaer and also I dont see the LocationUpdated() method which is called by the interface ?

  7. #7
    Registered User
    Join Date
    Dec 2009
    Posts
    42

    Re: GPS Positioning

    Wow, thanks for all the replies and links. I will take a read through everything 2mo morning. No, im not using the interface. The code I gave you is all that I have and all that I have tried.

    I do not know how to detect if GPS is available or not, that was one of the questions. But I will read through those links and take it from there.

    Thanks again for all the help

  8. #8
    Registered User
    Join Date
    Dec 2009
    Posts
    42

    Re: GPS Positioning

    Hey guys

    Just an update. The links you guys gave helped a lot. I know understand how things work a lot better. I sorted the problem out on the sony. But my nokia N81 is still asking me all the time. Funny thing is it doesnt ask me anything on google maps API or nokia maps and it gets my location correctly.

    My fone does not have GPS, it has options on getting location. Network and Bluetooth. My fone asks to allow app to use positioning data. I say yes, the GPS tries, but times out then asks me again and will do the same thing if I select yes again. No just asks again and again with no waiting.

    I dnt really want to turn off my fone options to ask-once as I dnt want this happening on some1 elses fone that has the same settings as mine.

    Thanks for all the help. I will let you guys know if I find a solution

  9. #9
    Registered User
    Join Date
    Dec 2009
    Posts
    42

    Re: GPS Positioning

    Hey guys.

    Ok, I sorted out the loop problem. It was just me being stupid. I put the method call in the paint function, so it was asking everytime the canvas was repainted.

    Thanks for all the help

  10. #10
    Registered User
    Join Date
    Dec 2009
    Posts
    1

    Unhappy Re: GPS Positioning

    Hi guys,this is prithesh here.I want to do my final year project on my own. I am plannin to develope a software for mobile, such that I would be able to retrieve phonenumber along with the name of person when I reach a perticular location with some kind of alert.Am suppose to do this using java only,I dont know how to start with guys please help me out please

Similar Threads

  1. GPS Listener - different behavior in emulator
    By neil.young in forum Symbian
    Replies: 4
    Last Post: 2009-12-15, 08:59
  2. GPS data using positioning module in Python s60
    By selimsolmaz in forum Symbian
    Replies: 2
    Last Post: 2009-07-08, 09:26
  3. [moved] GPS positioning module in Python s60
    By selimsolmaz in forum Symbian
    Replies: 0
    Last Post: 2009-07-07, 09:48
  4. Assisted GPS and Network based positioning
    By chandran.biju007 in forum Symbian
    Replies: 8
    Last Post: 2009-06-12, 11:15
  5. Thread and GPS positioning
    By kenneth@hrensberg.dk in forum Symbian
    Replies: 2
    Last Post: 2008-06-04, 15:53

Posting Permissions

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