zoukankan      html  css  js  c++  java
  • android开源项目旅游记录

    项目名字:AndTripLog-旅游日记

    一个很好的学习定位的开源项目,用的是google的定位系统,

    但是google的基站定位在国内很不稳定,基本处于不能用的状态

    本着自己动手丰衣足食的精神,果断改成百度的定位系统,

    写了一个百度定位的工具类:

    import java.util.List;
    
    import android.content.Context;
    import android.content.Intent;
    import android.content.SharedPreferences;
    import android.os.Handler;
    import android.os.Message;
    import android.telephony.SmsManager;
    import android.util.Log;
    import android.widget.Toast;
    
    import com.baidu.location.*;
    public class LocationUtils {
        private Context context;
        private boolean isLocationupdate=false;
        private String locationInfo;
        private Handler mhandler;
        private BDLocation bdLocation;
        public LocationClient mLocationClient = null;
        public MyLocationListenner myListener = new MyLocationListenner();
        
    	public LocationUtils(Context context,Handler myhandler){
    		this.context=context;
    		mhandler=myhandler;
    	}
    	
    	class MyLocationListenner implements BDLocationListener{
    
    		public void onReceiveLocation(BDLocation location) {
    			// TODO Auto-generated method stub
    			Log.d("AndTripLog","onReceiveLocation");
    			if (location == null)
    				return ;
    			Log.d("AndTripLog","onReceiveLocation is not null");
    			bdLocation=location;
    			isLocationupdate=true;
    			locationInfo="Latitude:"+location.getLatitude()+",Longitude:"+location.getLongitude();
    			mhandler.sendEmptyMessage(0);
    		}
    
    		public void onReceivePoi(BDLocation poiLocation) {
    			// TODO Auto-generated method stub
    			if (poiLocation == null){
    				return ; 
    			}
    		}
    		
    	}
    	public String getLocationInfo(){
    		return locationInfo;		
    	}
    	public BDLocation getLocation(){
    		return bdLocation;
    	}
    	public void startLocation(){
    		isLocationupdate=false;
    		mLocationClient = new LocationClient(context);	
    		setLocationOption();
    		mLocationClient.registerLocationListener(myListener);
    		Log.d("lostprevent","startLocation");
    		mLocationClient.start();
    	}
    	public boolean isupdate(){
    		return isLocationupdate;
    	}
    	public void stopLocation(){
    		isLocationupdate=false;
    		mLocationClient.stop();
    	}
    	private void setLocationOption(){
    		LocationClientOption option = new LocationClientOption();
    		option.setOpenGps(true);				
    		option.setServiceName("com.baidu.location.service_v3.3");
    		option.setPoiExtraInfo(false);	
            option.setAddrType("all");	
    		option.setScanSpan(3000);
            option.setCoorType("bd09ll"); 
            option.setPriority(LocationClientOption.NetWorkFirst);   
    		option.disableCache(true);		
    		mLocationClient.setLocOption(option);
    	}
    
    }
    


    相应的权限设置、需要添加的包见官方的介绍:

    http://developer.baidu.com/map/geosdk-android-developv3.3.htm

    通过此项目学习,可以很好的学习知识点:

    1.定位系统

    2.SQLite语句

    3.文件保存

    4.邮件发送

    项目源码下载地址:

    http://download.csdn.net/detail/txj8612/5353448




  • 相关阅读:
    ASP.NET MVC URL重写与优化(进阶篇)-继承RouteBase玩转URL
    MVC Razor模板引擎 @RenderBody、@RenderPage、@RenderSection及Html.RenderPartial、Html.RenderAction
    二叉树的建立&&前中后遍历(递归实现)&&层次遍历
    实现一个简单的散列表(HashMap)
    单向链表的删除及插入操作(以头插入法建立单向链表)
    单向链表的建立(头插入法)
    单向链表的建立(尾部插入法)
    链式队列(单向列表实现)
    顺序队列(数组实现)
    链式栈(单向链表实现)
  • 原文地址:https://www.cnblogs.com/xinyuyuanm/p/3071792.html
Copyright © 2011-2022 走看看