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 6949365
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T13:56:41+00:00 2026-05-27T13:56:41+00:00

I realize this question already exists, but I am having trouble implementing the solutions.

  • 0

I realize this question already exists, but I am having trouble implementing the solutions.

I’m using these questions as guidlines:

multiple proximity alert based on a service

set 2 proximity alerts with the same broadcast

Where I register the receiver:

final String NEAR_YOU_INTENT = "neighborhood.crodgers.example.activities.PROXIMITY_ALERT";
IntentFilter filter = new IntentFilter(NEAR_YOU_INTENT);
registerReceiver(new LocationReceiver(), filter);

Where the proximity alerts are added (Note: This is done in a service, hence the context grab):

LocationManager manager = (LocationManager) getSystemService(Context.LOCATION_SERVICE);
final String NEAR_YOU_INTENT = "neighborhood.crodgers.example.activities.PROXIMITY_ALERT";
Context context = getApplication().getApplicationContext();

int requestCode = 12345; //Spaceballs, anyone? anyone?
for (String domain : domainNames)
{
    String[] itemNames = itemGetter();
    for (String item : itemNames)
    {
        HashMap<String, String> attributes = getAttributesForItem(domain, item);                    

        Intent intent = new Intent(NEAR_YOU_INTENT);
        intent.putExtra(ADDRESS, attributes.get(ADDRESS));
        intent.setAction(""+requestCode);
        PendingIntent proximity = PendingIntent.getBroadcast(context, requestCode, intent, PendingIntent.FLAG_CANCEL_CURRENT);
        manager.addProximityAlert(Double.parseDouble(attributes.get(LATITUDE)),
                                  Double.parseDouble(attributes.get(LONGITUDE)), 
                                  6000f, -1, proximity);

        requestCode++;
    }
}

Originally, I was getting notified for the first proximity alert added (using notifications from the receiver). After adding

intent.setAction(""+requestCode);

I also tried:

intent.setData(""+ requestCode)

(I have seen this recommended in several other places) I stopped getting notifications all together.

  • 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-27T13:56:42+00:00Added an answer on May 27, 2026 at 1:56 pm

    Problem

    The problem is that you use setAction

    Intent intent = new Intent(NEAR_YOU_INTENT);
    intent.putExtra(ADDRESS, attributes.get(ADDRESS));
    intent.setAction(""+requestCode); //HERE IS THE PROBLEM
    

    What you end up doing in that last line is changing the action from NEAR_YOUR_INTENT to whatever request code happens to be. IE, you are doing the equivalent of

        Intent intent = new Intent();
        intent.setAction(NEAR_YOUR_INTENT);
        intent.setAction(""+requestCode); // THIS OVERWRITES OLD ACTION
    

    Extra Approach

    I suspect what you really want to do is add the requestCode as an extra to the intent so that you can retrieve it in your receiver. Try using

        Intent intent = new Intent(NEAR_YOU_INTENT);
        intent.putExtra(ADDRESS, attributes.get(ADDRESS));
        intent.putExtra("RequestCode", requestCode);
    

    Data Approach

    Alternatively, you could set the data to be your request code. IE, you could use

        Intent intent = new Intent(NEAR_YOU_INTENT);
        intent.putExtra(ADDRESS, attributes.get(ADDRESS));
        intent.setData("code://" + requestCode);
    

    Then you would need to alter your receiver then so that it can accept the “code://”
    schema. To do this:

    final String NEAR_YOU_INTENT = "neighborhood.crodgers.example.activities.PROXIMITY_ALERT";
    IntentFilter filter = new IntentFilter(NEAR_YOU_INTENT);
    filter.addDataScheme("code");
    registerReceiver(new LocationReceiver(), filter);
    

    Then you could probably use some method to parse out the id from the data field when you get your intent. IMO, the extras approach is easier.

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

Sidebar

Related Questions

I half realize that this question is probably asked already, but I'm not familiar
So I realize this question sounds stupid (and yes I am using a dual
I realize that this question is impossible to answer absolutely, but I'm only after
I realize that this question has been asked 100times but none that I have
I realize this perhaps a naive question but still I cant figure out how
I realize this is a basic question but I have searched online, been to
I realize this is more of a hardware question, but this is also very
I realize this is probably a hopelessly newbie question, but what is the difference
I realize there's no definitely right answer to this question, but when people talk
I've already looked at this question on representing strings in Python but my question

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.