获取我的位置 [英] Get my location

查看:113
本文介绍了获取我的位置的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个ListFragment,我希望得到我的位置。在我的清单我增加了这一点:

 <使用-权限的Andr​​oid:名称=android.permission.ACCESS_FINE_LOCATION/>
 

和我ListFragment's code是在这里,而不是作品:

 公共类ListaLugaresFragment扩展ListFragment实现LocationListener的{


    GoogleMap的GoogleMap的;
    地点位置;


    @覆盖
    公共查看onCreateView(LayoutInflater充气,容器的ViewGroup,
            捆绑savedInstanceState){
         V = inflater.inflate(R.layout.lista,集装箱,假);

         。LocationManager LM =(LocationManager)getActivity()getSystemService(getActivity()LOCATION_SERVICE。);
         lm.requestLocationUpdates(LocationManager.GPS_PROVIDER,0,0,这一点);


         返回伏;

    }

    @覆盖
    公共无效onLocationChanged(位置定位){
        // TODO自动生成方法存根

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


    }
 

解决方案

首先,你需要知道的关于 GPS,网络提供商,谷歌地图,以了解得到的位置。下面的例子是初学者知道如何获得来自全球定位系统和网络提供商的位置(lanlat值)

请点击此链接:

获取位置(经纬度)

如果你想获得一个位置名称则u必须了解SHA code和所有。

请点击此链接:

从GoogleMap的

获取位置

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


    }

解决方案

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

这篇关于获取我的位置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆