如果我在半徑之外時已經解決了,是否有可能發出通知?超出半徑範圍時發出通知谷歌地圖android
我的模式是這樣的: 我是學生,我的手機已安裝跟蹤器。如果我走進校外的範圍,我的申請會通知我的母親,我已經使用短信/電子郵件跳過課程。
你能指導我嗎?
這裏是我的代碼:
protected void onCreate(Bundle savedInstanceState) {
mLocationRequest = LocationRequest.create()
.setInterval(3)
.setFastestInterval(60)
.setPriority(LocationRequest.PRIORITY_HIGH_ACCURACY);
mGoogleApiClient = new GoogleApiClient.Builder(this)
.addConnectionCallbacks(this)
.addOnConnectionFailedListener(this)
.addApi(LocationServices.API)
.build();
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_student_activity);
}
public void circle()
{
Circle circle = mMap.addCircle(new CircleOptions()
.center(new LatLng(-xxxxxx,xxxxx))
.radius(2)
.strokeColor(Color.RED)
.strokeWidth(1)
.fillColor(Color.BLUE));
}
public void setUpMapIfNeeded()
{
SupportMapFragment mapFrag = (SupportMapFragment) getSupportFragmentManager().findFragmentById(R.id.map);
mMap = mapFrag.getMap();
mMap.setMyLocationEnabled(true);
circle();
}
public void onConnected(Bundle bundle)
{
Log.i(TAG,"Location Services Connected.");
Location location = LocationServices.FusedLocationApi.getLastLocation(mGoogleApiClient);
if(location==null)
{
LocationServices.FusedLocationApi.requestLocationUpdates(mGoogleApiClient,mLocationRequest,this);
}
else
{
handleNewLocation(location);
}
}
private void handleNewLocation(Location location)
{
Log.d(TAG,location.toString());
double currentLatitude = location.getLatitude();
double currentLongitude = location.getLongitude();
LatLng latLng = new LatLng(currentLatitude,currentLongitude);
MarkerOptions options = new MarkerOptions()
.position(latLng)
.title("I am here !");
mMap.addMarker(options);
mMap.moveCamera(CameraUpdateFactory.newLatLng(latLng));
mMap.animateCamera(CameraUpdateFactory.newLatLngZoom(latLng,21));
}
public void onLocationChanged(Location location) {
handleNewLocation(location);
}
看無論是地理範圍API或接近警告API – 2015-03-25 09:35:40
任何鏈接或關鍵字? – 2015-03-25 09:40:52