×

Discussion Board

Results 1 to 3 of 3
  1. #1
    Registered User
    Join Date
    Dec 2009
    Posts
    9

    problems with LocationListener

    hello forum.

    i have a problem with the LocationListener, my code is the fowllowing:
    Code:
    package com.visetics.gpsrecorder;
    
    import javax.microedition.location.Location;
    import javax.microedition.location.LocationException;
    import javax.microedition.location.LocationListener;
    import javax.microedition.location.LocationProvider;
    
    public class GPSSource implements LocationListener {
    
        private double longitude, latitude;
        private float altitude, speed;
        private int state;
        LocationProvider locationProvider;
    
        public GPSSource() throws LocationException {
    	LocationProvider provider = LocationProvider.getInstance(null);
    	provider.setLocationListener(this, -1, -1, -1);
        }
    
        public void locationUpdated(LocationProvider provider, Location location) {
    	if (location.isValid()) {
    	    longitude = location.getQualifiedCoordinates().getLongitude();
    	    latitude = location.getQualifiedCoordinates().getLatitude();
    	    altitude = location.getQualifiedCoordinates().getAltitude();
    	    speed = location.getSpeed();
    	}
    	System.out.println("locationUpdated");
        }
    
        public void providerStateChanged(LocationProvider provider, int newState) {
    	state = newState;
    	System.out.println(state);
        }
    
        public double getLongitude() {
    	return longitude;
        }
    
        public double getLatitude() {
    	return latitude;
        }
    
        public float getAltitude() {
    	return altitude;
        }
    
        public float getSpeed() {
    	return speed;
        }
    
        public int getState() {
    	return state;
        }
    
    }
    the code is running fine and as expected in suns wtk 2.5.2 emulator, but when i deploy the code to my e72 it doesn't work. The method locationUpdated is not invoked by the LocationListener. Experiments with threads and wait(), notify() has also not solved the problem.
    Thanks in advance for all suggestions and help.

    Daniel

  2. #2
    Nokia Developer Expert
    Join Date
    Aug 2007
    Posts
    1,595

    Re: problems with LocationListener

    Hello drindt,

    are you testing inside of a building, or outside?

    Check this discussion thread: http://discussion.forum.nokia.com/fo...d.php?t=200187

    Regards,
    r2j7
    [URL="http://library.forum.nokia.com/java"][B] >>> Java Developer's Library <<<[/B][/URL]
    [URL="https://www.developer.nokia.com/Resources/Support/Technical_support.xhtml"] [B]>>> Technical Support for Java ME development <<<[/B][/URL]
    [URL="https://publish.ovi.com/info/"][B]>>> Nokia Publish: reach millions of Nokia users worldwide through Nokia Store <<<[/B][/URL]

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

    Re: problems with LocationListener

    do you even get a valid LocationProvider ?
    I see you should be sending a Criterai along with the getInstance() but instead you are sending a null value...

    This can be found in the JavaDoc of the JSR-179 API :

    getInstance(Criteria criteria)
    This factory method is used to get an actual LocationProvider implementation based on the defined criteria.

    also give a look at this wiki article :
    http://wiki.forum.nokia.com/index.ph...aining_GPS_fix

Similar Threads

  1. Several problems with NMIT 4.1
    By jtalviva in forum Mobile Java Tools & SDKs
    Replies: 0
    Last Post: 2006-03-10, 10:59
  2. Series 60 CustomItem implementation problems?
    By fotis.chatzinikos in forum Mobile Java General
    Replies: 2
    Last Post: 2005-03-10, 15:48
  3. Problems with Developer Suite 2.2 and PC Suite 6.41.6
    By caiox in forum Mobile Java Tools & SDKs
    Replies: 0
    Last Post: 2005-02-20, 18:53
  4. NGage devkit problems
    By cambion in forum Symbian
    Replies: 3
    Last Post: 2004-12-07, 07:50

Posting Permissions

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