Locating current position in android without GPS

后端 未结 3 1787
耶瑟儿~
耶瑟儿~ 2020-12-31 20:40

I want to develop an application in which, if i open the app, it will show current location of my device. I want to do it without using gps. I have write a code for it. But

3条回答
  •  抹茶落季
    2020-12-31 20:53

    You should request 'mlocManager' to locate, and set its listener:

    public void getCurrentLocation()
    {
        if (mlocManager != null) {
            mlocManager .requestLocationUpdates(
                    LocationManager.NETWORK_PROVIDER, 0, 0, locListener );
            mlocManager .requestLocationUpdates(
                    LocationManager.GPS_PROVIDER, 0, 0, locListener );
        }
    
    }
    

提交回复
热议问题