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. Merging two apps

Hello All,

I built a testing ground application that does the Frame by Frame
Animation and I built a full app that cycles through some images and
sounds using the onclicklistener which utilizes if statements.


I want to have the frame by frame animation code run inside of one of
the if statements in my other app when it's called but I cannot figure
how to merge the code

Any ideas would be helpful.

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

2. execption while loadling providers

hi all,
When I try to start Location Manager, it throws exceptiones I post
here:

I/systemserver ( 44): starting Location Manager.
D/LocationManagerService (44): constructed LocationManager Service
E/LocationManagerService(44): Exception Loading Providers
E/LocationManagerService(44): java.lang.illegalArgumentException:
Key.length>31
E/LocationManagerservice(44): at android.os.systemproperties.get
(systemproperties.java:42)
E/LocationManagerService(44): at
com.android.internal.location.networkLocationProvider.isSupported
(NetworkLocationProvider.java:111)
E/LocationManagerService(44): at
com.android.server.LocationManagerService._loadProvidersNoSync
(LocationManagerService.java:348)
E/LocationManagerservice(44): at
com.android.server.LocationManagerService.loadProvidersNoSync
(LocationManagerService.java:340)
E/LocationManagerservice(44): at
com.android.server.LocationManagerService.loadProviders
(LocationManagerService.java:333)
E/LocationManagerservice(44): at
com.android.server.LocationManagerService.<init>
(LocationManagerService.java:447)
E/LocationmanagerService(44): at com.android.server.serverThread.run
(systemserver.java.234)
E/AndroidRuntime(44): Crash logging skipped, no checkin service

Does any one know what is going on here or meet the same question?
Please tell me if i missed anything to clarify, and any help will be
appreciated.
thanks.

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

3. Loading images from SDCard

4. Android and Epocrates

5. AlertDialog Question

6. Does this group need renaming?

7. Is Market developer console updating in real time?