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();
}