著作权人:开元福佑(北京)科技有限公司软件名称:一种老年人手机定位监护通信系统软件版本:v3.0代码长度:16598行1AndroidManifest.xml文件配置?xmlversion=1.0encoding=utf-8?manifestxmlns:android==cn.itcast.mainandroid:versionCode=1android:versionName=1.0applicationandroid:icon=@drawable/iconandroid:label=@string/app_nameactivityandroid:name=.Mainandroid:label=@string/app_nameintent-filteractionandroid:name=android.intent.action.MAIN/categoryandroid:name=android.intent.category.LAUNCHER//intent-filter/activityuses-libraryandroid:name=com.google.android.maps//applicationuses-permissionandroid:name=android.permission.INTERNET/uses-permissionandroid:name=android.permission.ACCESS_COARSE_LOCATION/uses-permissionandroid:name=android.permission.ACCESS_FIND_LOCATION//manifestMain.java文件packagecn.itcast.main;importjava.util.List;importcom.google.android.maps.GeoPoint;importcom.google.android.maps.MapActivity;importcom.google.android.maps.MapController;importcom.google.android.maps.MapView;importcom.google.android.maps.Overlay;importandroid.app.AlertDialog;importandroid.content.Context;importandroid.content.DialogInterface;importandroid.content.DialogInterface.OnClickListener;importandroid.graphics.Bitmap;importandroid.graphics.BitmapFactory;importandroid.graphics.Canvas;importandroid.graphics.Color;importandroid.graphics.Paint;importandroid.graphics.Point;著作权人:开元福佑(北京)科技有限公司软件名称:一种老年人手机定位监护通信系统软件版本:v3.0代码长度:16598行2importandroid.location.Address;importandroid.location.Criteria;importandroid.location.Geocoder;importandroid.location.Location;importandroid.location.LocationListener;importandroid.location.LocationManager;importandroid.os.Bundle;importandroid.view.MotionEvent;importandroid.widget.TextView;publicclassMainextendsMapActivity{privateMapControllermapController;privateGeoPointgeoPoint;privateStringmsg;@OverridepublicvoidonCreate(BundlesavedInstanceState){super.onCreate(savedInstanceState);setContentView(R.layout.main);//获得mapviewMapViewmapView=(MapView)this.findViewById(R.id.mapview);//地图的显示格式为交通图mapView.setTraffic(true);//设置可控mapView.setClickable(true);mapView.setEnabled(true);mapView.setBuiltInZoomControls(true);//得到gps设备的访问LocationManagerlocationManager=(LocationManager)getSystemService(Context.LOCATION_SERVICE);//设置gps定位配置Criteriacriteria=newCriteria();//设置显示精度criteria.setAccuracy(Criteria.ACCURACY_COARSE);//是否获得海拔数据criteria.setAltitudeRequired(false);//是否获得方向数据criteria.setBearingRequired(false);//是否允许运营商计费criteria.setCostAllowed(true);//设置耗电程度criteria.setPowerRequirement(Criteria.POWER_LOW);著作权人:开元福佑(北京)科技有限公司软件名称:一种老年人手机定位监护通信系统软件版本:v3.0代码长度:16598行3//获得服务供应商Stringprovider=locationManager.getBestProvider(criteria,true);//获取上一个定位点Locationlocation=locationManager.getLastKnownLocation(provider);//获得gps定位坐标信息Doublelatitude=location.getLatitude()*1E6;Doublelongitude=location.getLongitude()*1E6;//获得卫星定位点geoPoint=newGeoPoint(latitude.intValue(),longitude.intValue());//获得地图控制器mapController=mapView.getController();//设置地图显示初始化精度mapController.setZoom(12);mapController.animateTo(geoPoint);//实例化自定义绘图层MyOverlaymyOverlay=newMyOverlay();//为mapview添加绘图层mapView.getOverlays().add(myOverlay);//定义一个final,TextView,以备子类引用finalTextViewtextView=(TextView)findViewById(R.id.textview);LocationListenerlocationListener=newLocationListener(){@OverridepublicvoidonStatusChanged(Stringprovider,intstatus,Bundleextras){}@OverridepublicvoidonProviderEnabled(Stringprovider){//TODOAuto-generatedmethodstub}@OverridepublicvoidonProviderDisabled(Stringprovider){//TODOAuto-generatedmethodstub著作权人:开元福佑(北京)科技有限公司软件名称:一种老年人手机定位监护通信系统软件版本:v3.0代码长度:16598行4}@OverridepublicvoidonLocationChanged(Locationlocation){Doublelatitude=location.getLatitude()*1E6;Doublelongitude=location.getLongitude()*1E6;try{//获得精度纬度字符串msg=经度:+location.getLongitude()+\n;msg+=纬度:+location.getLatitude()+\n;//根据经纬度获得改点地址信息Geocodergc=newGeocoder(Main.this);ListAddressaddresses=gc.getFromLocation(latitude,longitude,1);if(addresses.size()0){//获得地址信息msg+=AddressLine:+addresses.get(0).getAddressLine(0)+\n;//获得国家名msg+=CountryName:+addresses.get(0).getCountryName()+\n;msg+=Locality:+addresses.get(0).getLocality()+\n;msg+=FeatureName:+addresses.get(0).getFeatureName();}textView.setText(msg);}catch(Exceptione){e.printStackTrace();}}};//注册位置监听器,1秒钟扫描1次locationManager.requestLocationUpdates(provider,1000,0,locationListener);}classMyOverlayextendsOverlay{//保证触控事件不重复操作著作权人:开元福佑(北京)科技有限公司软件名称:一种老年人手机定位监护通信系统软件版本:v3.0代码长度:16598行5privateintcount=0;@Overridepublicbooleandraw(Canvascanvas,MapViewmapView,booleanshadow,longwhen){//定义画笔Paintpaint=newPaint();paint.setColor(Color.RED);//定义屏幕点PointscreenPoint=newPoint();//gps点转屏幕点mapView.getProjection().toPixels(geoPoint,screenPoint);//获得gps标志点图片Bitmapbitmap=BitmapFactory.decodeResource(getResources(),R.drawable.flag);//绘制gps点图片canvas.drawBitmap(bitmap,screenPoint.x,screenPoint.y,paint);//绘制文字说明canvas.drawText(当前位置,screenPoint.x,screenPoint.y,paint);returnsuper.draw(canvas,mapView,shadow,when);}@OverridepublicbooleanonTouchEvent(Motio