IndexOutOfBoundsException when I call stopManagingCursor in an OnItemSelectedListener

by Jeffrey Yasskin » Sun, 08 Mar 2009 08:50:37 GMT


Sponsored Links
 Activity.performStop() contains the following loop (around line 3394
in the 1.0 SDK release and at
 http://android.git.kernel.org/?p=platform/frameworks/base.git ;a=blob;f=core/java/android/app/Activity.java;h=4dc4b6a48b85f9caad4234b8e29fafdc9260840c;hb=HEAD#l3504):

            final int N = mManagedCursors.size();
            for (int i=0; i<N; i++) {
                ManagedCursor mc = mManagedCursors.get(i);
                if (!mc.mReleased) {
                    mc.mCursor.deactivate();
                    mc.mReleased = true;
                }
            }

In my app, mc.mCursor.deactivate() calls (indirectly)
SimpleCursorAdapter.notifyDataSetInvalidated(), which calls
(indirectly) AdapterView.fireOnSelected(), which calls my
OnItemSelectedListener, which calls stopManagingCursor(), which
reduces the size of mManagedCursors, which makes the ArrayList.get()
call throw on the next iteration.

I'm calling stopManagingCursor to avoid the crash described at <http://
groups.google.com/group/android-developers/browse_thread/thread/
f6fabc180e8b517a/c04691d80f1e9135?lnk=gst&#c04691d80f1e9135> (and a
few other posts you can find by searching this group for
"SQLiteClosable").

I suspect this is a bug in Activity.performStop, which shouldn't
assume mManagedCursors is constant through a call to a user-provided
callback. Until the Android developers can fix the bug, I'm looking
for a workaround. Should I just abandon managed cursors, which don't
seem to work well with CursorAdapters? Is there a good way to prevent
my OnItemSelectedListener from being called during performStop()? Any
other ideas?

Thanks,
Jeffrey
--~--~---------~--~----~------------~-------~--~----~



IndexOutOfBoundsException when I call stopManagingCursor in an OnItemSelectedListener

by Jeffrey Yasskin » Sun, 08 Mar 2009 10:40:05 GMT


 That's a reasonable idea, thanks. Right now, I'm calling changeCursor
(null) for each of my adapters in onDestroy(), but if I run into
trouble with leaking cursors before I can set them into an adapter
I'll try removing the listeners.

Filed at  http://code.google.com/p/android/issues/detail?id=2174. 




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


Sponsored Links


Other Threads

1. Share - Samsung jabs iPhone's Retina Display, says AMOLED wins

Iphone4 with Multitasking + Retina display..battrenya seboros apa
yahh...


http://www.electronista.com/articles/10/06/09/samsung.says.iphone.4.lcd.too.hungry.low.color/

Samsung joined in the attacks on the iPhone 4's Retina Display with a
retort in the Korean media. A spokesperson for Samsung argued that
quadrupling the resolution actually had little impact on clarity, at
most three to five percent, and that that it would allegedly hike the
battery drain by as much as 30 percent. AMOLED is purportedly better
as it doesn't need a backlight and makes up for any resolution loss in
other ways, such as higher contrast with true black, more accurate
colors and no limits on viewing angles.

"Structurally, [Apple's] IPS LCD technology cannot catch up with
AMOLED display technology," the representative told the Korean Herald.

The iPhone 4 panel is still considered one of the most advanced
displays both for its "invisible pixel" effect and for overcoming most
of the perceived drawbacks of LCD, covering a very wide color gamut
and touting much wider viewing angles than the often cheap LCDs used
in other phones. Samsung's official also omitted well-known drawbacks
of AMOLEDs, including their high relative cost and poor visibility
outdoors. The Galaxy S may solve this by using a Super AMOLED screen
less vulnerable to the effect, but isn't completely immune.

The spokesperson did also partly confirm rumors and said an existing
AMOLED supply shortage may have dissuaded Apple from using the
technique in the iPhone 4, although he denied that Apple had reached
out to Samsung for the option. Prior reports had the iPhone using LCDs
because Samsung couldn't make enough AMOLEDs to match Apple's needed
production levels.

Also, Apple's $500 million contract with LG Display would likely
discourage the use of another contractor for screens, although the
deal wasn't struck exclusively for iPhones.

-- 
"Indonesian Android Community [id-android]" 

2. how to filter the objects (addresses) to display only the onscreen objects on map

Hi everyone,

I have an application that have a Google map on Google Android 1.5
since we have been working on the application for a long time, we are
not in stage of upgrading to the newest framework, so we are using 1.5

Now, I have map locations that are dynamically generated and drawn on
the map at run-time to visualize some streams,

Up to this point the applicaiton is working fine,

Now my problem is that I am trying to filter the objects ( addresses)
to visualize only the on-screen ones. I do NOT want to visualize the
addresses that are off-screen.

The way I am trying to do this is to check the screen-coordinates of
each object (address) before visualizing it, then it the coordinates
(x,y) more than (0,0) and less than (320, 460) >>> I should visualize
it.
I am trying to use this approach, but it is not working for some
reasons, I have tried many posts but could not understand why, there
must be something missing somewhere that I am not aware of.

Any help, suggestion will be highly appreciated.

Cheers
Hasn

-- 

3. Web Design Guidelines for the Nokia N900 v1.1

4. Update masalah download di spica

5. Store information in android setting menu

6. Upgrade AmonRa di Dream [WTA] Cara update Recovery ROM

7. Android Calender API