Hi,

I found out that RemoteCallbackList.getBroadcastItem(int) sometimes
returns null.  I have this code in my Service and it raises a null-
pointer exception:

...
    // instance variable of my Service
    final RemoteCallbackList<IProgressCallback> mCallbacks
            = new RemoteCallbackList<IProgressCallback>();


...
...
public boolean sendProgressCallback(String imgUri, int albumId, int
progressBytes, int progressPercent) {
        final QueuedImageUpload qiu = getUploadingImage(imgUri, albumId);
        if (qiu == null)
            return true;

        qiu.setSizeUploaded(progressBytes);

        final int totalSizePercent = mQueues.calculateRemainingSizePercent();
        final int N = mCallbacks.beginBroadcast();
        try {
                for (int i = 0; i < N; i++) {
                        try {
                                if 
(!mCallbacks.getBroadcastItem(i).progressChanged(qiu.getID(),
imgUri, albumId, progressPercent, totalSizePercent)) {
                                        return false;
                                }
                        } catch (RemoteException e) {
                                // The RemoteCallbackList will take care of 
removing
                                // the dead object for us.
                        }
                }
        }
        finally {
                mCallbacks.finishBroadcast();
        }
        return true;
}

This line is the one throwing a nullpointer exception:
"if (!mCallbacks.getBroadcastItem(i).progressChanged(qiu.getID(),
imgUri, albumId, progressPercent, totalSizePercent))"

- The mCallbacks is never null. It is declared as final.
- The local 'qui' stack-variable is never null. It is guarded by a
null-pointer check.

That only leads me to conclude that the call getBroadcastItem(i)
returns null. However, the documentation states that this method never
returns null. Is this a bug in Android?

This problem only happens on occasion (I can not reproduce it
consistently), but it happens often enough to be of concern for my
app.

BTW, someone else reported the same problem a while ago:

http://groups.google.com/group/android-developers/browse_thread/thread/804e27f717d4296d/7aa863a31c220b44?show_docid=7aa863a31c220b44&fwc=1

Thank you.
-- Anton Spaans
http://soft.antonspaans.com
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers-unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to