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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T02:26:26+00:00 2026-05-17T02:26:26+00:00

I just switched over from iPhone to Android and am looking for something similar

  • 0

I just switched over from iPhone to Android and am looking for something similar to where in the iPhone SDK, when a class finishes a certain task, it calls delegate methods in objects set as it’s delegates.

I don’t need too many details. I went through the docs and didn’t find anything (the closest I got was “broadcast intents” which seem more like iOS notifications).

Even if someone can point me to the correct documentation, it would be great.

Thanks!

  • 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-17T02:26:27+00:00Added an answer on May 17, 2026 at 2:26 am

    Never mind… found the answer here 🙂

    http://www.javaworld.com/javaworld/javatips/jw-javatip10.html


    Pasting from the article so as to preserve it:

    Developers conversant in the event-driven programming model of MS-Windows and the X Window System are accustomed to passing function pointers that are invoked (that is, “called back”) when something happens. Java’s object-oriented model does not currently support method pointers, and thus seems to preclude using this comfortable mechanism. But all is not lost!

    Java’s support of interfaces provides a mechanism by which we can get the equivalent of callbacks. The trick is to define a simple interface that declares the method we wish to be invoked.

    For example, suppose we want to be notified when an event happens. We can define an interface:

    public interface InterestingEvent
    {
        // This is just a regular method so it can return something or
        // take arguments if you like.
        public void interestingEvent ();
    }
    

    This gives us a grip on any objects of classes that implement the interface. So, we need not concern ourselves with any other extraneous type information. This is much nicer than hacking trampoline C functions that use the data field of widgets to hold an object pointer when using C++ code with Motif.

    The class that will signal the event needs to expect objects that implement the InterestingEvent interface and then invoke the interestingEvent() method as appropriate.

    public class EventNotifier
    {
        private InterestingEvent ie;
        private boolean somethingHappened; 
        public EventNotifier (InterestingEvent event)
        {
        // Save the event object for later use.
        ie = event; 
        // Nothing to report yet.
        somethingHappened = false;
        } 
        //...  
        public void doWork ()
        {
        // Check the predicate, which is set elsewhere.
        if (somethingHappened)
            {
            // Signal the even by invoking the interface's method.
            ie.interestingEvent ();
            }
        //...
        } 
        // ...
    }
    

    In that example, I used the somethingHappened predicate to track whether or not the event should be triggered. In many instances, the very fact that the method was called is enough to warrant signaling the interestingEvent().

    The code that wishes to receive the event notification must implement the InterestingEvent interface and just pass a reference to itself to the event notifier.

    public class CallMe implements InterestingEvent
    {
        private EventNotifier en; 
        public CallMe ()
        {
        // Create the event notifier and pass ourself to it.
        en = new EventNotifier (this);
        } 
        // Define the actual handler for the event.
        public void interestingEvent ()
        {
        // Wow!  Something really interesting must have occurred!
        // Do something...
        } 
        //...
    }
    

    That’s all there is to it. I hope use this simple Java idiom will make your transition to Java a bit less jittery.

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

Sidebar

Related Questions

Just switched over from eclipse to vs 2008 for debugging javascript, i feel more
We've just recently switched over from SVN to Mercurial, but now we are running
I am new to c#/.net and just switched over to it from classic asp(yesterday).
I just switched over from SVN where after a few changes to the trunk
I have just switched over from the old png transparency fix using a htc
I just switched my project from JUL (java.util.logging) to SL4J over JUL. Everything works
I just switched over to WPF from just regular C# .NET for the more
I just switched over from my development database to the production database, and I
I've just switched over from WinForms to wpf and in WinForms removing the whole
I am currently using a RadTreeView and just switched over to using Load-On-Demand (ServerSideCallback)

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.