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. Permanent Positions :: Android Developer :: Herndon, VA

Hello, 

Greetings!! 
Hope you are doing very well. 
One of our clients based out of Herndon, VA has 3 positions for Android
Developers. Below mentioned is the Job Description, Please go through it and
send across your resume to a...@mystrasolutions.com if you look forward to
take this one up. 

References of your friends and colleagues who might look to take it up are
welcome. 

Location:: Herndon , VA 
Type of Employment ::Full Time //C2H (As Preferred) 

Work Experience 
Minimum/General Experience: 
Three to five years of experience with application development, with one to
three years of experience with mobile applications. The candidate should
have a good in depth knowledge of relational databases. Experience in
consuming web services (SOAP/REST) and processing data (XML/JSON) is
essential. The candidate should meet the following minimal qualifications: 
. 2+ years of experience with Java.
. 2+ years of experience with Eclipse.
. At least 1 year of experience with Android SDK.
. At least 1 year of experience with WebServices.

Education and Training 

Minimum Education: 
Bachelor's degree in computer science, information systems, mathematics,
physics or related discipline.

I look forward to a quick response from you. 

Thanks 

Anuj Garg

Mystra Solutions
Phone: 732 659 1244
Email:   <mailto:a...@mystrasolutions.com> a...@mystrasolutions.com
Web:    <http://www.mystrasolutions.com/> www.mystrasolutions.com

 

 

 

-- 

2. Adding a ListView to a custom ViewGroup

I am trying to create a ListView and add it to a custom ViewGroup.
Here is my code:

public class HelloAndroid extends Activity
{
    private static final String[] PHOTOS_NAMES = new String[] {
        "Lyon",
        "Livermore",
        "Tahoe Pier",
        "Lake Tahoe",
        "Grand Canyon",
        "Bodie"
    };


    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        TextView tv = new TextView(this);
        MyViewGroup vg = new MyViewGroup(this);
        ListView lv = new ListView(this);

        tv.setText("Some Text");
        tv.layout(0, 0, 200, 40);
        vg.addView(tv);

        lv.layout(0, 40, 200, 200);

        final ArrayAdapter<String> adapter = new
ArrayAdapter<String>(this,
                android.R.layout.simple_list_item_1, PHOTOS_NAMES);

        lv.setAdapter(adapter);

        vg.addView(lv);

        setContentView(vg);
    }
}

When I do this, I see the "Some Text" TextView (which I also am adding
to my ViewGroup), but I don't see the ListView.  Now if I set the
ListView as the content view, (i.e. setContentView(lv)) it shows up.

Does anyone have any idea what I am doing wrong?

Thanks.

-- 

3. Forcing an ImageView to the size of a TableLayout cell

4. Negative comments from users

5. No resource found error

6. Problem flushing text to screen.

7. How to install an app programaticaly on Android