how to get the right format for GPS data in android
I have an app that does a query to a database.....asking for GPS data (latitude and longitude) which I animate on thr map afterwards.
Everything goes as expeected data like this
48868658
48869320
48869320 is returned and I display them on the map but when the cursor reaches to numbers like this:
48874808.0
I get the following error:
java.lang.NumberFormatException: unable to parse '4.88748e+07' as integer
which I don't understand cause in my code I did this:
longitude = (int)Integer.parseInt(c开发者_Python百科.getString(1));
latitude = (int)Integer.parseInt(c.getString(2));
p = new GeoPoint(latitude, longitude);
I've casted the whole thing to int....but I still get that error which stops my map.
Anyone can help me?
48874808.0 is a float or double, on the other hand, 48874808 is an integer.
To get the integral part, you can try something like this:
double d = Double.parse("48874808.0");
int integral = (int) d;
精彩评论