【问题标题】:Get my location获取我的位置
【发布时间】:2014-06-09 10:31:37
【问题描述】:

我有一个 ListFragment,我想获取我的位置。在我的清单中,我添加了这个:

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

我的 ListFragment 的代码在这里,但不起作用:

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


    }

【问题讨论】:

标签: android google-maps-android-api-2


【解决方案1】:

首先您需要了解 GPS、网络提供商、google MAP 以了解获取位置。下面的例子是让初学者知道如何从 GPS 和网络提供商获取位置(lanlat 值)

点击此链接:

Getting location (latlong)

如果您想获得位置名称,那么您必须了解 SHA 代码等所有信息。

点击此链接:

Getting location from googlemap

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-01-08
    • 2016-09-24
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多