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. Perbandingan antara cursorsense 32A1.2.4 dan Super Eclair 2.1 JitHack2_32ANRv09

dear all..
cuman pengen tahu sedikit review dari temen-temen untuk ROM magic
cursorsense32A1.2.4 dan super eclair 2.1Jithack2_32ANRv09 yang Jithack,
barang kali sudah ada yang menemukan kelebihan dan kekurangannya...
thx all...
*cape juga ngikutin perkembangan banyak ROM, bantji flash benerr.....*

-- 
"Indonesian Android Community [id-android]" 

2. Hero ga dpt sinyal.

Suhu2 sekalian, nubi mw mohon bantuannya neh. Dah seminggu ini, Hero
saya ga dpt sinyal, padahal dah make kartu indosat & xl. Itu knp ya?
Padahal ga pernah jatoh ato rsk sebelumnya. Mohon bantuannya ya. Thanks

-- 
"Indonesian Android Community [id-android]" 

3. How to get thumbnail picture from HTC Hero

4. Widget updated without my invoking

5. Android : List View or Spinner - Need your help guys

6. RingtoneManager getRingtone sometimes returns null

7. save image into sdcard not working