You Are Here:

Community: Developer Discussion Boards

#1 Old [moved] a code snippet example. i ask question about it - 2008-11-09, 04:46

Join Date: Nov 2008
Posts: 22
cenbek03
Offline
Registered User
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 08:54. Reason: Added code formating tags
Reply With Quote

#2 Old Re: a code snippet example. i ask question about it - 2008-11-09, 04:55

Join Date: Mar 2003
Posts: 16,947
Location: Bangkok
symbianyucca's Avatar
symbianyucca
Offline
Forum Nokia Expert
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.
Reply With Quote

#3 Old Re: a code snippet example. i ask question about it - 2008-11-09, 23:22

Join Date: Nov 2008
Posts: 22
cenbek03
Offline
Registered User
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?
Reply With Quote

#4 Old Re: a code snippet example. i ask question about it - 2008-11-10, 08:53

Join Date: Sep 2004
Posts: 7,953
Location: Tampere, Finland
ltomuta's Avatar
ltomuta
Offline
Forum Nokia Expert
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.
Reply With Quote

#5 Old Re: [moved] a code snippet example. i ask question about it - 2008-11-10, 09:12

Join Date: Nov 2008
Posts: 6
spcboy
Offline
Registered User
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.
Reply With Quote

#6 Old Re: [moved] a code snippet example. i ask question about it - 2008-11-10, 09:41

Join Date: Apr 2007
Posts: 1,757
Tiger79's Avatar
Tiger79
Offline
Forum Nokia Champion
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 ;)
Reply With Quote

#7 Old Re: [moved] a code snippet example. i ask question about it - 2008-11-12, 13:36

Join Date: Nov 2008
Posts: 22
cenbek03
Offline
Registered User
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...
Reply With Quote

#8 Old Re: [moved] a code snippet example. i ask question about it - 2008-11-12, 14:07

Join Date: Apr 2007
Posts: 1,757
Tiger79's Avatar
Tiger79
Offline
Forum Nokia Champion
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 ?
Reply With Quote
Reply « Previous Thread | Next Thread »
Display Modes
Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules

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

vB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Forum Jump
Similar Threads
Thread Thread Starter Forum Replies Last Post
[moved] error in code _c_ General Symbian C++ 4 2008-07-11 04:00
[moved] java.lang.IllegalArgumentException:Port format cisa Mobile Java Tools & SDKs 10 2008-06-23 17:36
Question about returned code... Dansco Python 4 2008-06-10 17:20
Code Optmization Question Spider_Eg Mobile Java General 2 2006-04-05 13:35
Testing HTTP client for Nokia 3650; Looking to share code nawkboy Symbian Networking & Messaging 2 2003-09-10 16:30

Rate This

 
Bookmark this page: DeliciousDiggFacebookGoogleYahooStumbleUponRedditDiigoTechnocratiTwitter  Share this page Share this page Print this Page Print this page Invite a friend Invite a friend
京ICP备05048969号    Email Newsletters Press Terms & Conditions Privacy Policy Sitemap Contact Us © 2009 Nokia