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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T08:11:55+00:00 2026-06-05T08:11:55+00:00

I would like to implement system of callbacks which looks like this (pseudo code):

  • 0

I would like to implement system of callbacks which looks like this (pseudo code):

final Listener listener = ListenerCtrl.addListener(new Listener() {
  void onNotify(String response){
    ListenerCtrl.unsetListener(listener);
} }

This code mean that after received message, i want to unscribe from future notifications. I found very attractive have this action inside of callback.

Here is my actual implementation:

final WebServiceMsgListener wml = new WebServiceMsgListener()
{
  public void onMsgNotify(JSONObject response, int ecode)
  {
    Log.v(TAG, "getSetStateProgressBar MSG_MGT_STATICINFO: onMsgNotify ecode" +
       ecode);
    authDelegate.unsetMsgListener(wml);
  }
};

authDelegate.addMsgListener(NAOMsg.MSG_MGT_STATICINFO, wml);

Unfortunately, my current implementation show me eclipse error:“The local variable wml may not have been initialized”

Question: how I can get round this, to finally unscribe inside of callback and dont have this error ?

  • 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-05T08:11:56+00:00Added an answer on June 5, 2026 at 8:11 am

    Change your code to:

    authDelegate.unsetMsgListener(this);
    

    this refers to the current object (whose onMsgNotify() is being executed at the time this statement is executed).

    Note: Although, the variable wml is available to the new object, it has not yet been initialized at the time of the creation of the object, hence the error. It is initialized right after the object is fully created.

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

Sidebar

Related Questions

is this okay to implement payment system on ios apps? I would like to
I would like to implement in this piece of code some instructions to increase
I'm building a multi-OS mirroring system which I would like to implement using a
I'm developing a MVC .Net site and would like to implement a CMS system.
I would like to implement a simple plugin system for my script. I'll be
I would like to implement an distributed Point-Of-Sale system, somewhat like the one described
I would like to implement a basic versioning system in a MySQL table. Let's
I would like to implement a map simmilar to this: http://gmaps-utility-library.googlecode.com/svn/trunk/markerclusterer/1.0/examples/advanced_example.html One of the
I would like to implement a parallel version of the code below using threads
I have a chicken-egg problem. I would like too implement a system in PHP

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.