I have given coordinates for latitude and longitude, and I want make a location object with those.There isn't a constructor that takes to doubles to make a location, so I tried like this:
Location l = null;
l.setLatitude(lat);
l.setLongitude(lon);
but it crashes. Any different idea?
Finding an address using longitude and latitude is easy if you have access to a computer or phone. You can use a reverse geocoding tool or Google Maps to pull up the address listed at your given coordinates.
Get the coordinates of a placeTouch and hold an area of the map that isn't labeled to drop a red pin. At the bottom, tap Dropped pin to find the coordinates.
If you don't have an address for a place, you can enter the GPS coordinates directly into the Maps location and the location will be displayed. Open the Maps app. Tap Search at the bottom of the screen. Enter the latitude and longitude coordinates in the search bar.
Just create a new Location with new Location("reverseGeocoded"); like this
GeoPoint newCurrent = new GeoPoint(59529200, 18071400);
Location current = new Location("reverseGeocoded");
current.setLatitude(newCurrent.getLatitudeE6() / 1e6);
current.setLongitude(newCurrent.getLongitudeE6() / 1e6);
current.setAccuracy(3333);
current.setBearing(333);
This crashes because you cannot call methods on an non existent object.
I presume you are talking about android.location.Location?
This is usually returned by the various positioning services of Android. What do you want to do with it?
Do you want to reverse geocode it? As in find an address for that geo coordinate?
Or do you want to use it as a "fake" position and feed it to other applications?
There are BTW two constructors. One takes the name of a positioning service and the other is a copy constructor and takes an existing Location.
So you could create a Location like this:
Location l = new Location("network");
But I do not think that this will result in something you want to have.
Here is a link to the documentation:
https://developer.android.com/reference/android/location/Location.html#Location%28java.lang.String%29
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With