Handler loses message after wait() and notify()

by fugu2.0 » Fri, 23 Apr 2010 08:02:06 GMT


Sponsored Links
 Hey Guys!

I have a problem handling messages in a Thread. My run-method looks
like this

public void run() {
   Looper.prepareLooper();
   parserHandler = new Handler {
      public void handleMessage(Message msg) {
         Log.i("","id from message: "+msg.getData.getString("id"));
         // further message handling
         this.wait();
      }
   }
}

I have several Activities sending messages to this thread, like this:

Message parserMessage = new Message();
Bundle data = new Bundle();
data.putString("id", realId);
data.putString("callingClass", "CategoryList");
parserMessage.setData(data);
parserMessage.what = PARSE_CATEGORIES_OR_PRODUCTS;

parserHandler = parser.getParserHandler();

synchronized (parserHandler) {
    parserHandler.notify();
    Log.i("","message ID:  " +
parserMessage.getData().getString("id"));
}

parserHandler.sendMessage(parserMessage);

The problem is that the run-method logs "id from message: null" though
"message ID" has a value in the Log-statement. Why does the message
"lose" it's data when being send to the thread? Has it something to do
with the notify? Thanks for your help

--



Other Threads

1. how to increase voice recording time?

Hi,

In my app, voice search is a feature. For that, user should say
something to do voice search. My requirement is to improve voice
recording time.
if any one knows to do this, please let me know. Any response would be
appreciated.

Best Regards
shailaja

-- 

2. how to increase voice recoding time?

Hi,

In my app, voice search is a feature. For that, user should say
something to do voice search. My requirement is to improve voice
recording time.
if any one knows to do this, please let me know. Any response would be
appreciated.

Best Regards
shailaja

-- 

3. Disappearing Images

4. SIGSEGV on free()

5. ListView.setChoiceMode with Custom Designed ListView rows Options

6. webview in tabs

7. Android Source code build error "Permission error"