-3

I have a ListFragment and I want to get the my location. In my Manifest I have added this:

<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />

and my ListFragment´s code is here, but not works:

public class ListaLugaresFragment extends ListFragment implements LocationListener {


    GoogleMap googleMap;
    Location location;


    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
            Bundle savedInstanceState) {
         v= inflater.inflate(R.layout.lista, container, false);

         LocationManager lm = (LocationManager) getActivity().getSystemService(getActivity().LOCATION_SERVICE);
         lm.requestLocationUpdates(LocationManager.GPS_PROVIDER, 0, 0, this);


         return v;

    }

    @Override
    public void onLocationChanged(Location location) {
        // TODO Auto-generated method stub

        Toast.makeText(getActivity(), location.getLatitude()+""+location.getLongitude(), Toast.LENGTH_LONG).show();


    }
user3714696
  • 91
  • 2
  • 8
  • http://stackoverflow.com/questions/23926311/not-getting-latitude-and-longitude-after-every-1-minute-in-android/23926531#23926531 it helps you – Ramki Anba Jun 09 '14 at 10:35
  • you may need to write [a bit more code to obtain the location, esp GPS](http://stackoverflow.com/questions/23962769/android-gps-incorrect-location-data-on-query) – Pararth Jun 09 '14 at 10:38

1 Answers1

0

First you need to know about GPS, Network Provider, google MAP to know getting location. Below example is for beginner to know how to get location(lanlat value) from the GPS and Network Provider

Follow this link:

Getting location (latlong)

If you want to get a location name then u must know about SHA code and all.

Follow this Link:

Getting location from googlemap

prabhakaran
  • 668
  • 2
  • 10
  • 33