K
K
koritesuk2021-01-13 15:41:14
Java
koritesuk, 2021-01-13 15:41:14

I don't understand what's wrong with assigning a variable?

I want to assign the width and longitude to a variable a = location.getLatitude();
but gives error -Required type:
String
Provided:
double
public double getLatitude()
Get the latitude, in degrees.
All locations generated by the LocationManager will have a valid latitude.
here is the code

private String formatLocation(Location location) {
        if (location == null)
            return "";

        String a, b, answerHTTP;
        a = location.getLatitude();
        b = location.getLongitude();
        String server = "http://demo.harrix.org/demo0011";
        HttpClient httpclient = new DefaultHttpClient();
        HttpGet httpget = new HttpGet(server + "?a=" + location.getLatitude() + "&b=" + location.getLongitude());
        try {
            HttpResponse response = httpclient.execute(httpget);
            if (response.getStatusLine().getStatusCode() == 200) {
                HttpEntity entity = response.getEntity();
                answerHTTP = EntityUtils.toString(entity);
            }
        }
        catch (ClientProtocolException e) {
        }
        catch (IOException e) {
        }

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
Dmitry Roo, 2021-01-13
@koritesuk

So it is written: you need a String, and you have a Double.
If you still need a String, Double has a .toString() method

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question