Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 5842137
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T11:58:43+00:00 2026-05-22T11:58:43+00:00

I have read several theads, blogs and forum but I didn’t find the solution

  • 0

I have read several theads, blogs and forum but I didn’t find the solution

I want a Proximity Alert so:

public class ProximityIntentReceiver extends BroadcastReceiver {        
@Override
        public void onReceive(Context  context, Intent intent) {
            String key= LocationManager.KEY_PROXIMITY_ENTERING;

            Boolean entering=intent.getBooleanExtra(key, false);
            Log.i(QUEST_PROXIMITY_ALERT,"entering");
            Log.i(QUEST_PROXIMITY_ALERT,"exiting");

        }       
    }  

In onCreateMethod:

 locationmanager=(LocationManager)getSystemService(Context.LOCATION_SERVICE);
 provider=locationmanager.getBestProvider(criteria, true);
 location=locationmanager.getLastKnownLocation(provider);
 if (location!=null) updateWithNewLocation(location);     
 locationmanager.requestLocationUpdates(provider, 0, 0, locationlistener);

And my location listener is:

private final LocationListener locationlistener= new LocationListener() {
        public void onLocationChanged(Location location) {
            Log.i("LOCATION_UPDATED","");
            updateWithNewLocation(location);
            mapview.invalidate();
    }
        public void onProviderDisabled(String provider) {
            //Message TO-DO
        }

        public void onProviderEnabled(String provider) { }

        public void onStatusChanged(String provider, int sttus, Bundle extras) { }
    };

At the beggining of the activity I show to the user a dialog to choose some data:

//Dialog to choose available EduQuests
       AlertDialog.Builder builder = new AlertDialog.Builder(this);
       builder.setTitle("Selecciona una búsqueda");
       builder.setSingleChoiceItems(items, -1, new DialogInterface.OnClickListener() {
           public void onClick(DialogInterface dialog, int item) {
               dialog.dismiss();
               mCurrent=item;
               Double lat=Double.parseDouble(mQuests.getItem(item).getPlace(0).getLatitude());
               Double longi=Double.parseDouble(mQuests.getItem(item).getPlace(0).getLongitude());
               GeoPoint point=new GeoPoint((int)(longi*1E6),(int) (lat*1E6));
               SetProximityAlert(point);
               mCurrentPlace=0; //First GeoPoint in the quest
               mQuests.getItem(mCurrent).getPlace(0).setVisibility(true);
               DrawPoints();
               mapview.invalidate();
           }
       });
      AlertDialog alert = builder.create();
      alert.show();   

And in the ClickListener of the Dialog as you I call the SetProximityAlert(point):

 private void SetProximityAlert(GeoPoint point) {    
        double lat=point.getLatitudeE6();
        double lng=point.getLongitudeE6();
        Log.i("SETTING PROXIMITY ALERT LATTITUDE--->",Double.toString(lat));
        Log.i("SETTING PROXIMITY ALERT LONGITUDE--->",Double.toString(lng));
        float radio= 20; //In meters    
        long expiration=-1;

        //Creo el Intent con la acción que hemos definido"
        Intent intent= new Intent(QUEST_PROXIMITY_ALERT);

        //Creo el PendingIntent pasándole
        PendingIntent proximityIntent=PendingIntent.getBroadcast(this,0, intent, 0);
        locationmanager.addProximityAlert(lat, lng, radio, expiration, proximityIntent);

        //Promixity Alert
        IntentFilter filter= new IntentFilter(QUEST_PROXIMITY_ALERT);
        registerReceiver(new ProximityIntentReceiver(),filter);      
    }

I calculate the distance to check if the alert should be fired in UpdateWithNewLocation() method that works fine:

private void updateWithNewLocation(Location location) {
          Double lat=Double.parseDouble(mQuests.getItem(mCurrent).getPlace(mCurrentPlace).getLatitude());
          Double longi=Double.parseDouble(mQuests.getItem(mCurrent).getPlace(mCurrentPlace).getLongitude());
          Location distlocation=new Location(provider);
          distlocation.setLatitude(lat);
          distlocation.setLongitude(longi);       
          Log.i("DISTANCE TO CURRENT POINT--->",Float.toString(location.distanceTo(distlocation))+"...metros");
          curlat=location.getLatitude();
          curlong=location.getLongitude();
          GeoPoint point=new GeoPoint((int)(curlat*1E6),(int) (curlong*1E6));
          OverlayItem overlayitem=new OverlayItem(point,"I'm here","This is my current position");
          if (curpositemizedoverlay==null) {
              curpositemizedoverlay=new QuestItemizedOverlay(this.getResources().getDrawable(R.drawable.me)); 
          }
          else {
              curpositemizedoverlay.removeItem(curpositemizedoverlay.size()-1);
          }           
          curpositemizedoverlay.addOverlay(overlayitem);
          mapOverlays.add(curpositemizedoverlay);
          mapview.invalidate();
    }

And private static String QUEST_PROXIMITY_ALERT="com.pekechis.ieda.proximityalert";

The package is name com.pekechis.ieda and the main activity IEDAQUEST.

I can see as my current position change as i change and the device position in DDMS. Also changes the distance to de POI (Point of Interest) that i shown in the log.

But the alert does not fire.

Any idea of what i’m doing wrong.

I thought It was a problem of declaring the filter in the manifest but as i have read there’s no need for that if I’m calling registereceiver.

Thanks in advance

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-22T11:58:44+00:00Added an answer on May 22, 2026 at 11:58 am

    well after many tries i was impossible for me to fire the Proximity Alert. I have chosen and alternative solutions (not optimal I suppose)

    I calculate the distance each time my current position changes. I have only one proximityalert at a time but I suppose that is no the best solution if I have many.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have read several forums but can't find the solution to this. int sIndex
I have read several post on both matters but I haven't seen anyone comparing
I have read several questions regarding this but I fear they may be out
I have read several posts about the configuration manager in VS2010 (or before) but
I have read through several articles which are alternatives to using setpixel/getpixel but I
I have read several different threads regarding this but all of them deal with
I have read in several blogs that we should create our own threads for
I have read several articles and questions on concept of foreign key vs independent
I have read in several places that it's possible to share the objects directory
I do not fully understand classes. I have read the python documentation and several

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.