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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T08:33:02+00:00 2026-06-17T08:33:02+00:00

I have implemented recurring alarms using the following example However, once an alarm goes

  • 0

I have implemented recurring alarms using the following example

However, once an alarm “goes off”/is recieved I want to update my ListView in the active Activity. I only have one activity with a ListView.

How do I execute my update UI method in the main activity class once an alarm is received? How do you call this from onReceive() in the AlarmReceiver (extends BroadcastReceiver) class

  • 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-17T08:33:03+00:00Added an answer on June 17, 2026 at 8:33 am

    The easiest way is to make your AlarmReceiver an inner class of your activity. This way it will have access to all fields and methods of your activity. If you don’t use it anywhere else, it might as well be anonymous.
    To make it update your activity only when it’s active, register your receiver in onResume() and unregister it in onPause(). Notice the IntentFilter specifying intent actions your BroadcastReceiver will respond to.

    Example:

    private BroadcastReceiver updateReceiver;
    
    //...
    
    @Override
    protected void onResume() {
        super.onResume();
    
        updateReceiver=new BroadcastReceiver() {
            @Override
            public void onReceive(Context context, Intent intent) {
                //your list update code here
            }
        };
        IntentFilter updateIntentFilter=new IntentFilter("update");
        registerReceiver(updateReceiver, updateIntentFilter);
    }
    
    @Override
    protected void onPause() {
        super.onPause();
    
        if (this.updateReceiver!=null)
            unregisterReceiver(updateReceiver);
    }
    

    If you still want your AlarmReceiver to be a separate class, pass some kind of callback to it during initialization:

    public interface AlarmReceiverCallback {
        public void onAlarmReceived(Intent intent);
    }
    
    //in your AlarmReceiver class:
    private AlarmReceiverCallback callback;
    
    public AlarmReceiver(AlarmReceiverCallback callback) {
        this.callback=callback;
    }
    
    @Override
    public void onReceive(Context context, Intent intent) {
        callback.onAlarmReceived(intent);
    }
    

    Initialization of your AlarmReceiver will look the following way:

    updateReceiver=new AlarmReceiver(new AlarmReceiverCallback() {
        @Override
        public void onAlarmReceived(Intent intent) {
            //your list update code here
        }     
    });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have implemented clean URLs using the following in my .htaccess RewriteEngine on RewriteCond
I have implemented a very basic sign up using email address+name, although I would
I am integrating with Authorize.NET I have implemented Charge Refund and Automated Recurring Payments
I am integrating with Authorize NET I have implemented Charge Refund and Automated Recurring
We are using NetBeans Platform 7.0.1, and have implemented support for a new language
Suppose i want something simple like the following: I have an core-algorithm, which randomly
I have implemented some functionality in C# using the yield statement with the function
I am using Ruby on Rails 3.2.2. I have implemented a Mixin module for
I have implemented REST API using PHP. This API access to MySQL Database. I
I have implemented paypal recurring payment without any trial period. Now I need to

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.