Giter VIP home page Giter VIP logo

location's Introduction

Location

基于android源生的组件

LLocation使用方法

由于是后台定位,需要现在清单文件中声明服务和定位权限。

     <service android:name="com.example.llocation.MyService" />
    <service android:name="com.example.llocation.YourService" />

之后进行初始化

	//初始化,传入activity,会先判断是否有权限,如果没有,需要先获得允许
	LLocationManager lLocationManager = new LLocationManager(this);
	//设置每次定位的间隔时间,单位为s,默认为10s
    lLocationManager.setTime(10);
	//设置每次定位的位置距离,单位为米,默认为10m 
	//当时间间隔和位置距离都设置时,以位置距离间隔定位,若一方为0,则以另一方间隔标准定位。
    lLocationManager.setDistance(10);
	//定位模式,分为MyLocation.GPS和MyLocation.NETWORK
    lLocationManager.setType(MyLocation.GPS);
	//定位状态的接口,分为开始,结束,失败,暂停,成功
    lLocationManager.setListener(new LLocation() {
        @Override
        public void OnSuccess(LocationData locationData) {
			//成功时返回Type(定位模式),location(经纬度等信息),Statellites(定位时的卫星个数)
            Log.e(TAG, "OnSuccess: " + locationData.toString());
        }
		//失败时返回错误码
		//556:没有定位权限
		//697:没有足够的卫星支持定位
		//491:定位失败
		//387:定位服务不在服务区
        @Override
        public void OnFailed(int error) {
            Log.e(TAG, "OnFailed: " + error);
        }
    });
	//开启后台服务
    lLocationManager.startService();

location's People

Contributors

hyyzt avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.