redrom
redrom

Reputation: 11632

Android, Java -> How to create and return Location object?

i'm getting 2 double values (lat, lon) from shared preferences in my application.

I would like to create method which returns Location object based on given lat and long values.

Is it possible or i must use any other return type (array, list)?

If Yes, please provide any simple example for my and others.

Thanks for Your advice.

Upvotes: 1

Views: 2349

Answers (2)

Fate Chang
Fate Chang

Reputation: 207

You can try this.

    Location location = new Location("providername");
    location.setLatitude(latitude);
    location.setLongitude(longitude);

Then you can use the location object;

Upvotes: 3

Digvesh Patel
Digvesh Patel

Reputation: 6533

LatLng latLng = new LatLng(Double.parseDouble(getIntent().getExtras().getString("lat")),
                            Double.parseDouble(getIntent().getExtras()
                                        .getString("lon")));

Upvotes: 2

Related Questions