Android系列只androidGooglemap小应用
2010-08-19 14:32:00 来源:WEB开发网核心提示:retLocation = null; 30 try 31 { 32 Criteria mCriteria01 = new Criteria(); 33 mCriteria01.setAccuracy(Criteria.ACCURACY_FINE); 34 mCriteria01.setAltitudeRequired
retLocation = null; 30 try 31 { 32 Criteria mCriteria01 = new Criteria(); 33
mCriteria01.setAccuracy(Criteria.ACCURACY_FINE); 34
mCriteria01.setAltitudeRequired(false); 35
mCriteria01.setBearingRequired(false); 36 mCriteria01.setCostAllowed(true); 37
mCriteria01.setPowerRequirement(Criteria.POWER_LOW); 38 strLocationProvider =
lm.getBestProvider(mCriteria01, true); 39 retLocation =
lm.getLastKnownLocation(strLocationProvider); 40 } 41 catch(Exception e) 42 { 43
// mTextView01.setText(e.toString()); 44 e.printStackTrace(); 45 } 46 return
retLocation; 47 } 48 49 /**位置监听器*/ 50 public final LocationListener 51
mLocationListener01 = new LocationListener() 52 { 53 public void
onLocationChanged(Location location) 54 { 55 // TODO Auto-generated method stub
56 /* 当手机收到位置更改时,将location传入取得地理坐标 */ 57 processLocationUpdated(location); 58 }
59 60 public void onProviderDisabled(String provider) 61 { 62 // TODO
Auto-generated method stub 63 /* 当Provider已离开服务范围时 */ 64
Toast.makeText(RingService.this, "无地理位置信息可用", Toast.LENGTH_SHORT).show(); 65 }
66 67 public void onProviderEnabled(String provider) 68 { 69 // TODO
Auto-generated method stub 70 } 71 72 public void onStatusChanged 73 (String
provider, int status, Bundle extras) 74 { 75 // TODO Auto-generated method stub
76 } 77 }; 78 79 /* 当手机收到位置更改,将location传入GeoPoint及MapView */ 80 private void
processLocationUpdated(Location location) 81 { 82 /* 传入Location对象,取得GeoPoint地理坐标
*/ 83 GeoPoint currentGeoPoint = getGeoByLocation(location); 84 /** 85 * */ 86
Log.i("service--------",currentGeoPoint.getLatitudeE6()+":"+currentGeoPoint.getLongitudeE6());
87 //读取记录的位置信息 88 Intent intent = new
Intent("android.provider.Telephony.SMS_RECEIVER2"); 89 Bundle bundle = new
Bundle(); 90 bundle.putDouble("latitude", currentGeoPoint.getLatitudeE6()); 91
bundle.putDouble("longitude", currentGeoPoint.getLongitudeE6()); 92
intent.putExtra("location", bundle); 93 // 发送广播 94 sendBroadcast(intent); 95
Tags:Android 系列 androidGooglemap
编辑录入:coldstar [复制链接] [打 印]更多精彩
赞助商链接