| Reply | « Previous Thread | Next Thread » |
|
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
|
|
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.
|
|
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?
|
|
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 Today's useful link: On device debugging - screencasts Yesterday's useful link: How do I start programming for Symbian OS? Latest blog post: Build without an SDK, test without a device
|
|
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. |
|
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 ;) |
|
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... |
|
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 | « Previous Thread | Next Thread » |
| Thread Tools | Search this Thread |
|---|---|
| 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 |