거리를 재서 일정 거리 이하가 되면 Toast 실행되게 하고 싶은데 왜 안되는지 모르겠습니다.

오류는 없구요.

제가 한 코딩으로는 거리가 멀든 가깝든 메시지가 계속 나와야 하는거 아닌가요?

아님 그 거리 안에 들어가야만 메시지가 나오나요?

 

왜 안되는지 아시는분 제발 좀 가르쳐 주세요

 

mapp.java

 

import android.app.PendingIntent;
import android.content.Context;
import android.content.Intent;
import android.location.Criteria;
import android.location.Location;
import android.location.LocationListener;
import android.location.LocationManager;
import android.os.Bundle;
import android.view.ViewGroup.LayoutParams;
import android.widget.ImageView;
import com.google.android.maps.GeoPoint;
import com.google.android.maps.MapActivity;
import com.google.android.maps.MapController;
import com.google.android.maps.MapView;
public class mapp extends MapActivity implements LocationListener {
 
 MapController mapControl;
 MapView map;
 LocationManager locationMgr = null;
 PendingIntent mPending;
 
 @Override
 protected void onCreate(Bundle icicle) {
  super.onCreate(icicle);
  setContentView(R.layout.main);
  
  map = (MapView) findViewById(R.id.map_view);
  
  mapControl = map.getController();
  locationMgr = (LocationManager) getSystemService(Context.LOCATION_SERVICE);
  Criteria criteria = new Criteria();
  criteria.setAccuracy(Criteria.NO_REQUIREMENT);
  criteria.setPowerRequirement(Criteria.NO_REQUIREMENT);
  locationMgr.requestLocationUpdates("gps", 1000, 0, mapp.this);
  
  Intent intent = new Intent(this, message.class);
  mPending = PendingIntent.getBroadcast(this, 0, intent, 0);
  
 }
 
 @Override
 public void onLocationChanged(Location location) {
  
  double lat = location.getLatitude();
  double lon = location.getLongitude();
  
  GeoPoint newPoint = new GeoPoint((int)(lat * 1E6), (int)(lon*1E6));
  
  mapControl.animateTo(newPoint);
  mapControl.setZoom(18);
  MapView.LayoutParams mapMarkerParams = new MapView.LayoutParams(
  LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT, newPoint,
  MapView.LayoutParams.TOP_LEFT);
  ImageView mapMarker = new ImageView(getApplicationContext());
  
  mapMarker.setImageResource(R.drawable.gmarker);
  
  map.addView(mapMarker, mapMarkerParams);  
  
  
  
 }
 @Override
 protected boolean isRouteDisplayed() {
  // TODO Auto-generated method stub
  return false;
 } 
 
 
 @Override
 public void onProviderEnabled(String provider) {
 
  super.onResume();
  locationMgr.addProximityAlert(35178456, 126909299, 500, -1, mPending);
  
 }
 @Override
 public void onProviderDisabled(String provider) {
 
  super.onPause();
  locationMgr.removeProximityAlert(mPending);
    
 }
 @Override
 public void onStatusChanged(String provider, int status, Bundle extras) {
 }
}

 

 

message.class

 

 package test.mapp;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.location.LocationManager;
import android.widget.Toast;
public class message extends BroadcastReceiver {
 
 public void onReceive(Context context, Intent intent){
  boolean bEnter = intent.getBooleanExtra(LocationManager.KEY_PROXIMITY_ENTERING, true);
  
  Toast.makeText(context, bEnter ? "거리 가까움" : "거리 멈", Toast.LENGTH_LONG).show();
  
 }
 }