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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T02:14:30+00:00 2026-06-03T02:14:30+00:00

I hope this will be simple question. I have main activity, on this activity

  • 0

I hope this will be simple question.
I have main activity, on this activity I create an instance of some class. How to send some event form one class to main one? How to setup some kind a listener to send notifications between classes. Only option what I know/use right now is to keep reference to parent class and call directly some function from child class.

I’m wonder if it possible to create something like is in ActionScript, where I can call to dispatchEvent(new Event(“name”)) and later setup addEventlistener(“name” function) ??

  • 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-03T02:14:31+00:00Added an answer on June 3, 2026 at 2:14 am

    If “I implement some class” means that you have declared a nested class inside your Activity class than nested non-static class will have a reference to parent class object.

    In general, you can always create dispatcher/listener pattern your self. Create listener interface and add either addListener or setListener method to class that will dispatch event.

    Example of listener:

    public interface IAsyncFetchListener extends EventListener {
        void onComplete(String item);
        void onError(Throwable error);
    }
    

    Example of event dispatcher:

    public class FileDownloader {
        IAsyncFetchListener fetchListener = null;
        ...
        private void doInBackground(URL url) {
            ...
            if (this.fetchListener != null)
                this.fetchListener.onComplete(result);
        }
    
        public void setListener(IAsyncFetchListener listener) {
            this.fetchListener = listener
        }
    }
    

    Example of class with event listener:

    public class MyClass {
    
        public void doSomething() {
            FileDownloader downloader = new FileDownloader();
    
            downloader.setListener(new IAsyncFetchListener() {
    
                public void onComplete(String item) {
                    // do something with item
                }
    
                public void onError(Throwable error) {
                    // report error
                }
            });
    
            downloader.start();
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm new to CodeIgniter and I hope that my question will have a simple
I have a simple question. I designed a C# class where I got some
hope this will be a quick easy question, I've just tried my app on
I hope this question will not be rejected as there is no code. But
I hope this is a quick question I hope. I need to write some
Hopefully this question has a simple answer i'm overlooking! I have an IIS webserver
Not a web developer so i hope you will spare me if this question
I have a very simple (rather stupid) question, I hope someone can clear my
I hope this is a simple enough question for any SQL people out there...
I have really simple and lame question (i hope it's simple). I'm quite new

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.