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

  • Home
  • SEARCH
  • 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 6156197
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T20:34:08+00:00 2026-05-23T20:34:08+00:00

I use addProximityAlert: Intent intent = new Intent(getString(R.string.intent_message_location_fetched)); PendingIntent proximityIntent = PendingIntent.getBroadcast(this, 0, intent,

  • 0

I use addProximityAlert:

Intent intent = new Intent(getString(R.string.intent_message_location_fetched));
PendingIntent proximityIntent = PendingIntent.getBroadcast(this, 0, intent, 0);
locationManager.addProximityAlert(LAT, LONG, RADIUS, 0, proximityIntent);

As I understand intent with action R.string.intent_message_location_fetched should be fired after location will be around LAT LONG.
(R.string.intent_message_location_fetched = com.myapp.client.MyActivity.LocationFetched)

Then I’m trying to create BroadcastReceiver class:

public class MyBroadcastReciver extends BroadcastReceiver {
    MyActivity mainActivity;
    public MyBroadcastReciver(MyActivity activity)
    {
        mainActivity = activity;
    }
    @Override
    public void onReceive(Context context, Intent intent) {
        mainActivity.ShowToast("Recived : " + intent.getAction());
    }
}

And register receiver in MyActivity class:

public void onCreate(Bundle savedInstanceState)
    {
        super.onCreate(savedInstanceState);

        myReciver = new MyBroadcastReciver(this);
        IntentFilter intentFilter = new IntentFilter();
intentFilter.addAction(getString(R.string.intent_message_location_fetched));
        registerReceiver(myReciver, intentFilter);
...

But nothing happens when I’m in LAT LONG location.
What’s wrong?
I’ve tried register Receiver in manifest, but it didn’t help.

P.S. When I’ve used getActivity instead of getBroadcast this worked OK and restored my Activity if it was dead.

  • 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-23T20:34:09+00:00Added an answer on May 23, 2026 at 8:34 pm

    OK, guys. Tnx anyway.
    Now I understan how Intents works.
    The main thing was (I suppose so) that I’ve used different contexts.

    Now I have my own class with addProximityAlert function called with PendingIntent. Instead of this I pass WrapperContext activityContext (when I’m creating my class I pass an exemplar of my Activity):

    //Prepare proximity Intent
    proximityIntent = new Intent(activityContext.getString(R.string.intent_message_location_fetched));
    proximityPendingIntent = PendingIntent.getBroadcast(activityContext, 0, proximityIntent, 0);
    locationManager.addProximityAlert(latitude, longitude, (float) radius, -1, proximityPendingIntent);
    

    Notice the expiration value = -1 ! Or your intent probably will be dead before you catch it.

    The second thing – I’m registered intent-filter with action=”@strings/my_message” in manifest:

    <activity ...>
                ...
            <intent-filter>
                    <action android:name="@string/intent_message_location_fetched"/>
            </intent-filter>
    </activity>
    

    And then I have this in my own class constructor:

    //Create and register receiver
            BroadcastReceiver mReceiver = new BroadcastReceiver() {
    
                @Override
                public void onReceive(Context context, Intent intent) {
                    if(intent.getAction().equals(context.getString(R.string.intent_message_location_fetched)) 
                             && intent.getExtras().getBoolean(LocationManager.KEY_PROXIMITY_ENTERING))
                     {
                        Toast.makeText(activityContext, "LOCATION INTENT WORKS!", Toast.LENGTH_SHORT).show();
                     }
                }
            };
            activityContext.registerReceiver(mReceiver, new IntentFilter(activityContext.getString(R.string.intent_message_location_fetched)));
    

    I hope this will be useful for someone.

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

Sidebar

Related Questions

use this website a lot but first time posting. My program creates a number
Use Case I need to package up our kml which is in a String
use Control::CLI; $cli = new Control::CLI('SSH'); $cli->connect(Host=>'10.10.10.10',Username=>'user',Password=>'pwd'); $cli->waitfor('>'); $cli->print('Show XXXXXXXXXXXXXXXXXXXX| grep Active'); @f=$cli->waitfor('>'); print
use WWW::Mechanize; my $mech = WWW::Mechanize->new; $mech->get( $url ); say $mech->text; How could I
Use trap to capture signals like this: i=-1;while((++i<33)); do trap echo $i >> log.txt
use Parallel::ForkManager; use LWP::Simple; my $pm=new Parallel::ForkManager(10); our $a =0; @LINK=( 10,203, 20, 20
use DBI(); What is causing this insert to fail to err 1, the SELECT
Use case is this: I want to unit test (in browser, QUnit or something
Use new MediaPlayer by Yahoo. Content parse automatic - greate, but I use ajax
'''use Jython''' import shutil print dir(shutil) There is no, shutil.move, how does one move

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.