0

I am getting an array out of bounds error in an Android application, and I cannot figure out how to resolve this problem. It seems as if all the relevant checks are done.

My code is as follows:

private final Handler handler = new Handler() {
    @Override
    public void handleMessage(android.os.Message msg) {
        if (msg.what == GLES20VideoRenderer.MESSAGE_TIMING) {
            Bundle data = msg.getData();

            if ((data != null) && !data.isEmpty()) {
                    if (data.containsKey("utc_timestamp_ms")) {
                        updateTimeDisplay(data.getLong("utc_timestamp_ms"));
                    }

                    if (data.containsKey("streaming")) {
                        if (overlayBusy != null) {
                            if (overlayBusy.getVisibility() != View.INVISIBLE) {
                                overlayBusy.setVisibility(View.INVISIBLE);
                            }
                        }
                    }
            }
        }
    }
};

I get the following error:

10-30 07:53:07.923: E/AndroidRuntime(19371): java.lang.ArrayIndexOutOfBoundsException: length=0;    index=0
10-30 07:53:07.923: E/AndroidRuntime(19371):    at android.util.ArrayMap.indexOf(ArrayMap.java:113)
10-30 07:53:07.923: E/AndroidRuntime(19371):    at android.util.ArrayMap.get(ArrayMap.java:366)
10-30 07:53:07.923: E/AndroidRuntime(19371):    at android.os.Bundle.getLong(Bundle.java:1029)
10-30 07:53:07.923: E/AndroidRuntime(19371):    at android.os.Bundle.getLong(Bundle.java:1016)

Any help will be appreciated.

Chris Stratton
  • 39,853
  • 6
  • 84
  • 117
  • That does seem odd - and at first glance as if the problem is in platform code, not yours. See if you can dump out the Bundle somehow. Also try it on a different device. – Chris Stratton Oct 30 '14 at 08:22
  • The above Error shows that you donot have any thing in your array – Hasnain Oct 30 '14 at 10:04
  • What's your updateTimeDisplay() method looks like? – WoookLiu Oct 30 '14 at 10:51
  • Undid 3rd party edits which conceal the true nature of the issue. This is not your generic "index out of bounds" issue, as while that is ultimately happening, it is happening within Android platform code that has been handed a Bundle object **already verified to contain the requested key** - not an Array. – Chris Stratton Oct 30 '14 at 17:36

1 Answers1

1

https://code.google.com/p/android/issues/detail?id=76888

This may be caused by a potential race condition in OS<5.1 devices.

Some Noob Student
  • 14,186
  • 13
  • 65
  • 103