×

Discussion Board

Page 1 of 2 12 LastLast
Results 1 to 15 of 18
  1. #1
    Regular Contributor
    Join Date
    Sep 2008
    Posts
    103

    How to find current Location using LBS library in java me?

    Hi!
    Can u please tell me, how to find current location using the programm in java me.
    I try to get the current geocodes(Latitude and Longitude) using the following code,

    criteria = new Criteria();
    criteria.setHorizontalAccuracy(500);
    criteria.setVerticalAccuracy(500);
    criteria.setPreferredPowerConsumption(Criteria.NO_REQUIREMENT);
    locationProvider = LocationProvider.getInstance(criteria);
    locationProvider.setLocationListener(locationListener,-1,-1,-1);
    Location location=locationProvider.getLocation(-1);
    QualifiedCoordinates qualifiedCoordinates=location.getQualifiedCoordinates();
    System.out.println("Previous coords are Longitude("+qualifiedCoordinates.getLongitude()+") Latitude("+qualifiedCoordinates.getLatitude()+")");


    This run successfully on S60 3rd edition emulator(printing the coords). But when I try to run the same on device(s) like E71, N95 and Nokia 5800. It leads an exception like,
    LocationException:location request time out
    It shows same exception even I changed (around to half an hour) the timeout parameter value at locationProvider.getLocation(<<secs>>);
    pls, suggest me the solution----

  2. #2
    Super Contributor
    Join Date
    Apr 2007
    Posts
    2,708

    Re: How to find current Location using LBS library in java me?

    well that most probably means you didnt have a GPS fix at the moment...
    so set the getLocation at 10 seconds and stay outside for a couple of minutes at the least...

  3. #3
    Regular Contributor
    Join Date
    Sep 2008
    Posts
    103

    Re: How to find current Location using LBS library in java me?

    Quote Originally Posted by Tiger79 View Post
    well that most probably means you didnt have a GPS fix at the moment...
    so set the getLocation at 10 seconds and stay outside for a couple of minutes at the least...
    Thanks for ur reply,
    but, I have already check in that way also by giving 500 seconds. Even though, I didn't got the location info. Another point is my mobile also has the GPS service on that time.
    At last, I put -1 instead of seconds(for provider default timeout).
    Can, u tell me what is the problem in that, the program be run on emulator successfully. I phased this problem only on device(s).
    Pls, suggest me-----

  4. #4
    Super Contributor
    Join Date
    Apr 2007
    Posts
    2,708

    Re: How to find current Location using LBS library in java me?

    you know for sure that you have configured your device so that apps are able to use gps as a locationprovider ?
    somewhere in the phone options menu's you have the option to select/deselect various methods of positioning (bluetooth, assisted gps, integrated gps, network-based)...

  5. #5
    Regular Contributor
    Join Date
    Mar 2008
    Posts
    198

    Re: How to find current Location using LBS library in java me?

    Your code is wrong. It should be more like this:

    Code:
    public LocationHandler() {
      try {
        provider = LocationProvider.getInstance(null);
    
        if (provider == null) {
          System.out.println("LocationHandler constructor: no provider");
        }
        else {
          provider.setLocationListener(this, 1, -1, -1);
        }
      }
    
      catch (Exception e) { }
    }
    
    public void locationUpdated(LocationProvider p, Location l) {
      try {
        if (!l.isValid()) return;
        QualifiedCoordinates qc = l.getQualifiedCoordinates();
      }
    
      catch (Exception e) { }
    }
    - Mike
    NAVTEQ Network for Developers
    The community for developing innovative location-based applications
    http://NN4D.com

  6. #6
    Super Contributor
    Join Date
    Apr 2007
    Posts
    2,708

    Re: How to find current Location using LBS library in java me?

    well he was trying to poll instead of using the interrupt-driven interface,
    so if you're using the interrupt-driven method please take into account you will have to implement the LocationListener interface...

    hhmmm, i'm sorry I wasn't looking at all :P
    i completely missed the setLocationListener part and concentrated on the getLocation method :P
    only one of the two methods should be used, you are using both methods at once
    as mike is suggesting if you use the locationlistener interface then you will have to implement the locationUpdated method

  7. #7
    Regular Contributor
    Join Date
    Sep 2008
    Posts
    103

    Re: How to find current Location using LBS library in java me?

    Quote Originally Posted by Tiger79 View Post
    well he was trying to poll instead of using the interrupt-driven interface,
    so if you're using the interrupt-driven method please take into account you will have to implement the LocationListener interface...

    hhmmm, i'm sorry I wasn't looking at all :P
    i completely missed the setLocationListener part and concentrated on the getLocation method :P
    only one of the two methods should be used, you are using both methods at once
    as mike is suggesting if you use the locationlistener interface then you will have to implement the locationUpdated method
    I even try with only LocationProvider.getLocation() by removing the locations listener. Even after, I couldn't got the location information.

    Can u give me the sample, pls---

  8. #8
    Super Contributor
    Join Date
    Apr 2007
    Posts
    2,708

    Re: How to find current Location using LBS library in java me?

    well personally I prefer the LocationListener interface, cause it will supply a Location every x seconds, and after just a fast check on Location.isValid() you can do whatever you need to do...
    for code samples you can search around, there are loads and loads of it, ebven in this form (tip : Search butoon on the upper-left side of ur screen )....
    Still you do have configured your device so that applications can use GPS right ?
    Also does the Nokia Maps application work (N95)?

  9. #9
    Regular Contributor
    Join Date
    Mar 2008
    Posts
    198

    Re: How to find current Location using LBS library in java me?

    Quote Originally Posted by neeraja.nokia View Post
    Can u give me the sample, pls---
    I gave you an example. Did you try that?

    When you removed the setLocationListener() did you also remove the implements LocationListener from the class?

    - Mike
    NAVTEQ Network for Developers
    The community for developing innovative location-based applications
    http://NN4D.com

  10. #10
    Regular Contributor
    Join Date
    Sep 2008
    Posts
    103

    Re: How to find current Location using LBS library in java me?

    Quote Originally Posted by mikemoore View Post
    I gave you an example. Did you try that?

    When you removed the setLocationListener() did you also remove the implements LocationListener from the class?

    - Mike
    NAVTEQ Network for Developers
    The community for developing innovative location-based applications
    http://NN4D.com
    Yes, I tried ur sample. And, I removed loctionListener also with implemented method. I used only getLocation(int secs) method of LocationProvider. Even after, I couldn't get that. This is the only device problem, in the emulator the programm be successfully run.
    Thanks in advance-----

  11. #11
    Registered User
    Join Date
    Jan 2009
    Posts
    39

    Re: How to find current Location using LBS library in java me?

    dear neeraja.nokia ,
    as Tiger said in a post above you will need to see if your GPS is actually working.
    I think the best way is using the GPS/GPS data in your device menu and see if it gives you a position. If no, there would be little chance (if any) that you can get a coordination in your own midlet.

    If the answer is no for a long time, try to change the location (move the device to somewhere else!)

    BR,
    Kaveh MB

  12. #12
    Regular Contributor
    Join Date
    Mar 2008
    Posts
    198

    Re: How to find current Location using LBS library in java me?

    Quote Originally Posted by neeraja.nokia View Post
    This is the only device problem, in the emulator the programm be successfully run.
    This normally means nothing. An emulator is just an emulator... many things work in the emulator that do not work on the device. The fact that you cannot get it to work on any device would normally mean that there is something wrong with the code.

    Can you get any location fix using the phone? e.g. using Nokia Maps, or Tools/GPS Data/Position ?

    - Mike
    NAVTEQ Network for Developers
    The community for developing innovative location-based applications
    http://NN4D.com

  13. #13
    Super Contributor
    Join Date
    Apr 2007
    Posts
    2,708

    Re: How to find current Location using LBS library in java me?

    any news ? is your internal application able to get a gps fix ?

  14. #14
    Regular Contributor
    Join Date
    Sep 2008
    Posts
    103

    Re: How to find current Location using LBS library in java me?

    Quote Originally Posted by Tiger79 View Post
    any news ? is your internal application able to get a gps fix ?
    Sorry for late reply, Still I couldn't got the location. Is this location problem. I heared that some location haven't GPS Data that is (coordinate details Latitude and Longitude).

  15. #15
    Regular Contributor
    Join Date
    Mar 2008
    Posts
    198

    Re: How to find current Location using LBS library in java me?

    Quote Originally Posted by neeraja.nokia View Post
    Sorry for late reply, Still I couldn't got the location. Is this location problem. I heared that some location haven't GPS Data that is (coordinate details Latitude and Longitude).
    All locations have a latitude and longitude. Not all locations have a good GPS signal... e.g. in streets with tall buildings, under trees, indoors. This is why we ask if you can get a signal using existing utilities, e.g. Tools/Connectivity/GPS Data/Position.

    You might also want to check that you actually have the GPS turned on (Tools/Settings/General/Positioning/Positioning Methods)

    - Mike
    NAVTEQ Network for Developers
    The community for developing innovative location-based applications
    http://NN4D.com

Similar Threads

  1. Can’t launch application on 6630
    By kaffemannen in forum Symbian
    Replies: 8
    Last Post: 2005-06-29, 10:49
  2. "Not found" on target 9500
    By alex_makarov in forum Symbian
    Replies: 10
    Last Post: 2004-12-03, 14:05
  3. Improvment of JAVA MMS library v1.1
    By Arturas in forum General Messaging
    Replies: 16
    Last Post: 2003-10-30, 07:43

Posting Permissions

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