Map API

Nutiteq Maps Lib SDK enables developing advanced mobile mapping applications.
Platforms: Android, RIM BlackBerry, Java ME (J2ME)
Download maps API SDK »
Untitled Document

Products

» View demos
» Downloads

Uudised

Viimane: Thu, 15 Mar 2012 14:51:08
Teema: Vabad töökohad pakkuda
Veel uudiseid »

GPS info

7 replies [Last post]
noksi
User offline. Last seen 36 weeks 6 days ago. Offline
Joined: 08/13/2010

When I trun on log and GPS I get in console something like this:
Debug > time: 6:54:390
Debug > Loc info - course:0.0 time:1312656854390 method:0 speed:0.0 isvalid:true addresinfo:null xtrainfo:null
I need time info from above. How to get this info from locationSource(LocationAPIProvider). I did't find any api for this and I need this informations. Also, it should be fine if someone can explain all info from above. What information we can get from GPS?

jaak
User offline. Last seen 4 days 19 hours ago. Offline
Joined: 06/19/2008

Information what you get from GPS depends on location source.

For J2ME there is sample MIDLet "com.nutiteq.location.GPSMIDlet" in sample package which has different location methods included, with both GPS, Bluetooth GPS and Cell-ID (on some phones).

Also be aware that in real device GPS location could take quite long time: minimum is about 30 seconds, and if you do not have AGPS then it could take many minutes for the first fix, even if you are outside building. Inside building sometimes you never get it.

/JaakL

noksi
User offline. Last seen 36 weeks 6 days ago. Offline
Joined: 08/13/2010

Actually, all I need is to get time from GPS (starting from 1970), not from phone. Is this possible? I am almost 100% sure that we can get time from GPS. But how?

I use this code for GPS:
locationSource = new LocationAPIProvider(1000);
marker = new NutiteqLocationMarker(new PlaceIcon(gpsPresentImage),new PlaceIcon(gpsConnectionLost), 1000, true);
locationSource.setLocationMarker(marker);
mapComponent.setLocationSource(locationSource);

jaak
User offline. Last seen 4 days 19 hours ago. Offline
Joined: 06/19/2008

Why do you need it? Timestamp of latest GPS location can be retrieved, but it can be outdated. If you have good signal, then it is about 1 sec old (depending on your update setting), if not they it can be any time older.

Following could give you GPS time, but I'm not sure if this is something really useful by itself:


lastGpsTimestamp = ((javax.microedition.location.Location) locationSource.getNativeLocation()).getTimestamp();

/JaakL

noksi
User offline. Last seen 36 weeks 6 days ago. Offline
Joined: 08/13/2010

I need this info to do some client security which depends of time, something like to prevent user to spam. In one hour I will let user only X times to make some action... And my app during run will always use gps so this info is good for my app. I don't need to implement on server this security. If I use System.currentTimeMillis() user can easy change time on there phone in future and security check for number of some user action in last hour will not work.

I look for this on net but I did't find how to get timestapm from GPS. Thanks.

noksi
User offline. Last seen 36 weeks 6 days ago. Offline
Joined: 08/13/2010

I try on J2ME and Android, and on Android it return timestamp from GPS, but on J2ME it return timestamp from phone.

When I print on J2ME timestamp from phone(currentTimeMillis()) and GPS(locationSource.getNativeLocation()).getTimestamp()) it is always the same value even if I change time on phone... And this is bad for me. On Android it is OK. So if there isn't way to get timestamp from GPS on J2ME then I will get timestamp from server...

jaak
User offline. Last seen 4 days 19 hours ago. Offline
Joined: 06/19/2008

Some J2ME devices NMEA raw GPS data when you use getExtraInfo() (see http://www.developer.nokia.com/document/Java_Developers_Library_v2/GUID-4AEC8DAF-DDCC-4A30-B820-23F2BA60EA52/javax/microedition/location/Location.html#getExtraInfo(java.lang.String) ). This can include timestamp in some format.

However, most phones do not give anything there, and even if they give then there is no requirement that NMEA has proper timestamp info. I think I've seen some NMEA in Nokia S60 phones, but I can be wrong also.

In practise probably you cannot relay on it. Btw, why don't you use timestamp server and some security to ensure that the server communication is not tampered?

/JaakL

noksi
User offline. Last seen 36 weeks 6 days ago. Offline
Joined: 08/13/2010

Yes, I will use timestamp from server, that's the best solution.