RemoteCallbackList.getBroadcastItem(int) sometimes returns null

by Dianne Hackborn » Fri, 13 Mar 2009 09:25:16 GMT


Sponsored Links
 The callbacks are just stored in a HashMap, and the entries there are never
set null (actually that field is final), so I don't really see how that can
happen.  Are you sure you aren't potentially doing this loop from different
threads without doing your own synchronization?

On Thu, Mar 12, 2009 at 6:07 PM, Streets Of Boston



> 



RemoteCallbackList.getBroadcastItem(int) sometimes returns null

by Dianne Hackborn » Fri, 13 Mar 2009 09:27:36 GMT


 m actually could you see if it is the -last- ones that are null?  The code
that makes the list gets a count from the HashMap, and then iterates through
its values and puts them in the array, and returns the original count. So
if that count is different than the number it iterated over, that could be a
problem. I'll change it to return the actual number it iterated over, but
in theory these shouldn't be different.

On Thu, Mar 12, 2009 at 6:25 PM, Dianne Hackborn <hack...@android.com>wrote:



--
Dianne Hackborn
Android framework engineer
hack...@android.com

Note: please don't send private questions to me, as I don't have time to
provide private support. All such questions should be posted on public
forums, where I and others can see and answer them.

--~--~---------~--~----~------------~-------~--~----~


Sponsored Links


RemoteCallbackList.getBroadcastItem(int) sometimes returns null

by Dianne Hackborn » Fri, 13 Mar 2009 16:54:17 GMT


 On Thu, Mar 12, 2009 at 8:08 PM, Streets Of Boston





No, it only locks internally in beginBroadcast() to create the list.  If you
may have multiple threads calling beginBroadcast(), they need to do their
own synchronization, holding your own lock from before calling
beginBroadcast() to after finishBroadcast().

-- 
Dianne Hackborn
Android framework engineer
hack...@android.com

Note: please don't send private questions to me, as I don't have time to
provide private support.  All such questions should be posted on public
forums, where I and others can see and answer them.

--~--~---------~--~----~------------~-------~--~----~



RemoteCallbackList.getBroadcastItem(int) sometimes returns null

by Dianne Hackborn » Sat, 14 Mar 2009 00:59:18 GMT


 On Fri, Mar 13, 2009 at 7:27 AM, Streets Of Boston





I'm not sure what you mean by "either way" -- if you are doing this from
multiple threads, your threads can clobber the list, which can lead to this
kind of problem.

-- 
Dianne Hackborn
Android framework engineer
hack...@android.com

Note: please don't send private questions to me, as I don't have time to
provide private support.  All such questions should be posted on public
forums, where I and others can see and answer them.

--~--~---------~--~----~------------~-------~--~----~



RemoteCallbackList.getBroadcastItem(int) sometimes returns null

by Dianne Hackborn » Sat, 14 Mar 2009 02:29:18 GMT


 If your callbacks are oneway, the easiest thing to do is put it all in a big
synchronized() block.  Be aware though that if the callback is into the
local process, it will still be synchronous, so holding a lock while doing
this can be a problem.

Usually the safest thing is to have a handler that you post a message to,
which does the callbacks.  Then you don't need any locking since the
broadcasts are serialized by the handler.

On Fri, Mar 13, 2009 at 10:55 AM, Streets Of Boston <flyingdutc...@gmail.com







-- 
Dianne Hackborn
Android framework engineer
hack...@android.com

Note: please don't send private questions to me, as I don't have time to
provide private support.  All such questions should be posted on public
forums, where I and others can see and answer them.

--~--~---------~--~----~------------~-------~--~----~



Other Threads

1. Android Firmware on Hero

Hello all!!

Yesterday i was in Google I/O conference at Google office in Madrid.
It's impressive what new version "Froyo" for Android can do and what
comes with it. And Google TV it's comming with many good
possibilities. Unfortunately I had to go before the end of the
conference and I have some cuestions that I wanted to do but I
couldn't. Maybe some of  you can answer:

I'm developing with 2.1 or 2.2 SDK with the emulator and including
libraries like TTS in my applications, but when I try it in my
terminal it forces to close. My cell is a HTC HERO (FIRM 1.5), I think
it doesn't support last interesting libraries.

1. Could I upgrade my firm to 2.1 or better, to "Froyo", to test my
applications?. If not, will be possible soon?
2. Where can i find the firm?
3. Will google upgrade all terminals almost to 2.1? (I have read there
ara about 30% of users in firm 1.5, like me, and my applications are
not supported for all that clients).
4. Do you know where can I buy a cell with Froyo with a good price?
5. I have heared I can do a "wrapper" to allow users in 1.5 use the
application.Is it possible?

Sorry for so long post.

-- 

2. Can you change menu order based on user action?

Is it possible to change the order of the menu items based on the user
choosing a particular preference?

Is it possible for the user to re-order menu items so their most used
options appear as icons when the menu button is pushed?

-- 

3. Android camera and Google TV

4. Analytics for Android Market

5. how to create a listeView in which get information from Data base (text and image)

6. Problem with sending email with attachment

7. Intent.ACTION_PICK to pick an image in other directory