×

Discussion Board

Results 1 to 8 of 8

Hybrid View

  1. #1
    Registered User
    Join Date
    Nov 2008
    Posts
    22

    [moved] a code snippet example. i ask question about it

    Helo. i write the belowing code. This code runs correctly in my application. i want to ask this. "speed" and "course" variables on this code returns "NAN". Where do i make wrong?
    The second question is that : the location updates become once in a minute, but i want to update once in 5-10 second. Is it possible ? Thanks.

    Code:
    public void Connection () throws LocationException
        {
            if(istracking==false)
            {
                istracking=true;
                screen.setCurrent(finf);
                finf.append("Connecting......");
                    cr=new Criteria();
                    cr.setHorizontalAccuracy(25);
                    provider=LocationProvider.getInstance(cr);
                    if(provider!=null)
                      provider.setLocationListener(this,-1,-1,-1);
             }
            
        }
        
    public void locationUpdated(LocationProvider provider, Location location)
         {
            upDate t=new upDate();
            t.start();
         }
    
        public void providerStateChanged(LocationProvider provider, int newState) {
        }
    
        
        public class upDate extends Thread
        {        
            public void run()
            {
               
                try
                {
                    loc=provider.getLocation(60);
                    if(loc.isValid())
                    {
                        String s="";
                        finf.deleteAll();
                        coor=loc.getQualifiedCoordinates();
                         double lt=coor.getLatitude();
                        double lon=coor.getLongitude();
                        float course=loc.getCourse();
                        double speed=loc.getSpeed();
                        long time=loc.getTimestamp();
                        
                        s="Langitude: "+lt+"\\nLongitute: "+lon+
                        "Course: "+course+"\Speed : "+speed+"\nTime: "+time;
                        finf.append(s);
                        
                    }
                }
                catch(Exception ex)
                {
                }
          }
    Last edited by ltomuta; 2008-11-10 at 07:54. Reason: Added code formating tags

  2. #2
    Nokia Developer Moderator
    Join Date
    Mar 2003
    Location
    Lempäälä/Finland
    Posts
    29,165

    Re: a code snippet example. i ask question about it

    I would try the Wiki and find some already working sample codes from there. One thing that is definetely wrong with your code is at least the variable t that is local variable and thus is not valid after the function returns.

  3. #3
    Registered User
    Join Date
    Nov 2008
    Posts
    22

    Re: a code snippet example. i ask question about it

    What is the wrong on my code? "t" is local,but it is used at one place,and when it begins to run,(i think) thread is worked.Am i right?

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

    Re: a code snippet example. i ask question about it

    If you're asking somebody to spot an error in your code you should rather use the language specific forums. Whatever your problem is, it's Java related, not LBS.
    -- 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 2008
    Posts
    6

    Re: [moved] a code snippet example. i ask question about it

    Hi, I don't want to comment on your code. Just answer your questions.:-)

    Most GPS device has their own hardware specification, it defines the maximum refresh interval, accuracy and other possible parameters. The LBS API just gives an common rule that should be followed when implementing APIs. so, as developer you could only point out your preference behavior you want the hardware to perform. API implementation would do all its best to fulfill your requirements rather than exactly MATCH.

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

    Re: [moved] a code snippet example. i ask question about it

    it seems to me u are making a mess out of it :P
    u are trying to implement a locatiolistener, which when returns a location u fire up a thread which doesnt even use that location, instead ur thread asks a new location with loc.getlocation(60)...

    I'd say have a look at the wiki or even better have a look at the API specification...
    there are two methods to obtain a location, one is using locationlistener and one is by directly asking for one, u are trying to use both in one piece of code, thats just asking for problems

  7. #7
    Registered User
    Join Date
    Nov 2008
    Posts
    22

    Re: [moved] a code snippet example. i ask question about it

    helo. Thanks for anwers.
    Tiger79, you had said that there are 2 methods for taking location. i use both of them in my code.Is this wrong? I ask because my code is working.It acquires longituse,latitude informations.Again thanks...

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

    Re: [moved] a code snippet example. i ask question about it

    sure it might work,
    but it takes up more resources, it might get conflicting at some point, and why use 2 methods if hte info u are getting from both is practically the same ?

Similar Threads

  1. [moved] error in code
    By _c_ in forum Symbian
    Replies: 4
    Last Post: 2008-07-11, 03:00
  2. [moved] java.lang.IllegalArgumentException:Port format
    By cisa in forum Mobile Java Tools & SDKs
    Replies: 10
    Last Post: 2008-06-23, 16:36
  3. Question about returned code...
    By Dansco in forum Symbian
    Replies: 4
    Last Post: 2008-06-10, 16:20
  4. Code Optmization Question
    By Spider_Eg in forum Mobile Java General
    Replies: 2
    Last Post: 2006-04-05, 12:35
  5. Testing HTTP client for Nokia 3650; Looking to share code
    By nawkboy in forum Symbian Networking & Messaging (Closed)
    Replies: 2
    Last Post: 2003-09-10, 15:30

Posting Permissions

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