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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T20:20:38+00:00 2026-06-01T20:20:38+00:00

I am using cwac-Location Poller (from here ) to constantly poll user location and

  • 0

I am using cwac-Location Poller (from here) to constantly poll user location and display location based notifications. This all is working fine but now I am trying to attach another BroadcastReceiver so that if my application is in foreground, instead of displaying notification animate the google map to current user location. But for some reason I can’t get it working.

onCreate() method of MapActivity I have following code to start poller:

@Override
public void onCreate(Bundle savedInstanceState) {
   .....

    alarmManager = (AlarmManager) getSystemService(ALARM_SERVICE);

    Intent i = new Intent(this, LocationPoller.class);

    Bundle bundle = new Bundle();
    LocationPollerParameter parameter = new LocationPollerParameter(bundle);
    parameter.setIntentToBroadcastOnCompletion(new Intent(this, LocationReceiver.class));
    parameter.setProviders(new String[] {LocationManager.GPS_PROVIDER, LocationManager.NETWORK_PROVIDER});
    parameter.setTimeout(60000);
    i.putExtras(bundle);

    pendingIntent = PendingIntent.getBroadcast(this, 0, i, 0);

    alarmManager.setRepeating(AlarmManager.ELAPSED_REALTIME_WAKEUP, 
                SystemClock.elapsedRealtime(), PERIOD, pendingIntent);                                 
}

in onResume() method I am registering another receiver using registerReceiver() method:

@Override
protected void onResume() {
    super.onResume();
    IntentFilter intentFilter = new IntentFilter(com.commonsware.cwac.locpoll.LocationPollerParameter.INTENT_TO_BROADCAST_ON_COMPLETION_KEY);
    intentFilter.setPriority(1);
    registerReceiver(locationReceiver, intentFilter);
}

Where locationReceiver looks like:

private BroadcastReceiver locationReceiver = new BroadcastReceiver() {      
    @Override
    public void onReceive(Context context, Intent intent) {
        Log.d(TAG, "mapActivity called");
        abortBroadcast();
    }
};

And in order to send ordered broadcast to multiple receiver I have modified LocationPollerService to use sendOrderedBroadcast instead of sendBroadcast

public void onLocationChanged(Location location) {
      handler.removeCallbacks(onTimeout);
      Intent toBroadcast = createIntentToBroadcastOnCompletion();

      toBroadcast.putExtra(LocationPollerResult.LOCATION_KEY, location);        
      sendOrderedBroadcast(toBroadcast, null);
      quit();
}

Now the problem is my dynamically registered receiver never get called but the one mentioned in AndroidManifest.xml does:

    <receiver android:name=".receiver.LocationReceiver" />
    <receiver android:name="com.commonsware.cwac.locpoll.LocationPoller" />
    <service android:name="com.commonsware.cwac.locpoll.LocationPollerService" />
  • 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-06-01T20:20:39+00:00Added an answer on June 1, 2026 at 8:20 pm

    Your problem is in a disconnect between the IntentFilter you create in Java and your createIntentToBroadcastOnCompletion() implementation, which you did not include in your question. Your IntentFilter is expecting a broadcast with a certain action string — the Intent you are creating in createIntentToBroadcastOnCompletion() apparently does not include this action string.

    BTW, with respect to “And in order to send broadcast to multiple receiver”, sendBroadcast() is perfectly capable of sending broadcasts to multiple receivers.

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

Sidebar

Related Questions

Hi I'm using the TouchListView control from here: https://github.com/commonsguy/cwac-touchlist and I've added some buttons
using xmltextreader, how would I load a hashtable. XML: <base><user name=john>2342343</user><user name=mark>239099393</user></base> This was
Using the http://www.ifans.com/forums/showthread.php?t=132024 post from another question i am allowing the user to enter
Using Java, how can I extract all the links from a given web page?
I'm currently using cwac-endless adapter for my application. For this one, I don't know
Im using the endless adapter http://github.com/commonsguy/cwac-endless however whenever i return false (because i dont
Using C#, I need a class called User that has a username, password, active
I am using cwac-endless adapter , and i am facing problems in disabling the
Using mercurial, I've run into an odd problem where a line from one committer
using a binary search tree I need to add to a vector all int

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.