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. Activity to service on click of BACK (arrow key on dev) and bring the same activity on click of notification

Hello android developers..

 i am not much familiar with service's and use of aidl...here is the
scenario i look to put fwd Kindly help on it...Working on android sdk
1.1

1) Activity is launched and location updates are taken and they are
print on the activity using textview..
2)On click of BACK (arrow key on dev) .. activity goes to destroy mode
(which i dont want)...and call the service with dispatches the
notification with the icon ..Still the location updates are ON..
3)When i click the notification icon..i must get back the same
activity which was getting the updates and updated values printed on
the text view...


I wonder is this possible .. i have gone through some apps such as My
Tracks, Buddy Runner...which works well on this scenario...

I hope some android developers give a favorable reply and help in
solving the problem...

I referred the LocalService and LocalServiceController examples from
API demo ..but the activity is destroyed on the click of BACK ...

Kindly help on this...
Regards,
Sheik
--~--~---------~--~----~------------~-------~--~----~

2. Bug in the MediaStore Content Provider ?

Hello

My mp3 application is using the MediaStore content provider and I
noticed strange behaviour that is even reproducible on the native
android mp3 player.

1) Start emulator with SD card and some songs already on it
2) Start native mp3 player
3) See the songs that you have
4) Now push a new song to the SDC card
5) Restart the native MP3 player

Result: The new song is not visible. If I restart the emulator then
the song will be visible

Expected Result : The new song should be visible and accesible from
the conent provider after after it has been added to sdcard.

I first of all reproduced on my application, but I see that it also
effects the native player which must be using the MediaStore content
provider aswel.

This behaviour looks like a bug to me ?

I am using 1.5r2 of the SDK

Thanks !
--~--~---------~--~----~------------~-------~--~----~

3. Can we go back to older versions?

4. Passing pointer to AsyncTask that changes GUI to onRetainNonConfigurationInstance?

5. No intent to terminate(end) the call programmatically

6. help with google accounts

7. java.lang.VerifyError - please help me some one