android-loadermanager

Why is onLoadFinished called again after fragment resumed?

≡放荡痞女 提交于 2019-11-29 07:45:07
问题 I have a peculiar issue with Loaders. Currently I am unsure if this is a bug in my code or I misunderstand loaders. The app The issue arises with conversations (imagine something similar to Whatsapp). The loaders I use are implemented based on the AsyncTaskLoader example. I am using the support library. In OnCreate, I start a loader to retrieve cached messages. When the CachedMessageLoader finishes, it starts a RefreshLoader to retrieve (online) the newest messages. Each loader type as a

ActionBarSherlock + Maps + Loaders = java.lang.NoClassDefFoundError

放肆的年华 提交于 2019-11-29 04:17:27
Edit: For a detailed how-to, check out my answer . I'm struggling with it for two days now, hope someone can help. I'm trying to use the newest ActionBarSherlock (4.0) with a MapView. I knew it's problematic with fragments, but I don't need them in this activity. But I need Loaders and it appears, that to use Loaders I have to extend the FragmentActivity too. No problem, I thought, we have the android-support-v4-googlemaps from Pete Doyle. As suggested on many SO threads and Google Groups I build the ABS with android-support-v4-googlemaps JAR (android-support-v13-r7-googlemaps.jar actually)

A few questions about SQLite database cursors in Android

梦想与她 提交于 2019-11-29 00:17:01
To implement database access in my application I followed Lars Vogel tutorial , but I'm very confused about a couple of things... 1) Every time a call is made to fetchTodo a new cursor will be created and returned. Leaving the previous cursor for the garbage collector. So, if I don't use startManagingCursor or even the CursorLoader for that matter, should I call a .close() on the cursor when I'm done with it ? Outside of fetchTodo scope of course, example: Cursor cursor = mNotesAdapter.fetchTodo(); // do something... cursor.close(); I'm done with this cursor and new one will be created on the

ExpandableListFragment with LoaderManager for Compatibility Package

Deadly 提交于 2019-11-28 23:37:48
问题 I want to make my ExpandableListActivity compatible with Honeycomb. I am wondering why there is no ExpandableListFragment for the Compatibility Package. Is there a way to make ExpandableListView work with the normal Fragment class? How do I load the Cursors with the LoaderManager? 回答1: I had the same problem. I didnt find a solution for this, so I decided to implement the ExpandableListFragment myself based on a combination of the android.support.v4.app.ListFragment (Compatibility API) and

Android error: java.lang.IllegalStateException: trying to requery an already closed cursor

女生的网名这么多〃 提交于 2019-11-28 20:33:32
environment (Linux/Eclipse Dev for Xoom Tablet running HoneyComb 3.0.1) In my app I'm using the camera (startIntentForResult()) to take a picture. After the picture is taken I get the onActivityResult() callback and am able to load a Bitmap using a Uri passed via the "take picture" intent. At that point my activity is resumed and I get an error trying to reload the images into a gallery: FATAL EXCEPTION: main ERROR/AndroidRuntime(4148): java.lang.RuntimeException: Unable to resume activity {...}: java.lang.IllegalStateException: trying to requery an already closed cursor at android.app

What's the purpose of startManagingCursor?

允我心安 提交于 2019-11-28 18:50:27
Ok, the documentation states that it lets the Activity manage the cursor's lifecycle. But I don't really see the point of it since when the activity is destroyed, any references to the newly created cursor should be also erased and then the cursor itself is left to perish in the next garbage collecting cycle. So why bother? You should not rely on cursors being destroyed by the garbage collector... a cursor represents a significant amount of resources: all of the data held by the cursor, plus the connection to the content provider that owns the cursor which also means requiring that its process

LoaderManager with multiple loaders: how to get the right cursorloader

喜欢而已 提交于 2019-11-28 15:11:11
To me it's not clear how to get the right cursor if you have multiple Loaders. Lets say you define two different Loader with: getLoaderManager().initLoader(0,null,this); getLoaderManager().initLoader(1,null,this); then in onCreateLoader() you do different things depending on the id: @Override public Loader<Cursor> onCreateLoader(int id, Bundle arg1) { if (id==0){ CursorLoader loader = new CursorLoader(getActivity(), MaterialContentProvider.CONTENT_URI,null,null,null,null); }else{ CursorLoader loader = new CursorLoader(getActivity(), CustomerContentProvider.CONTENT_URI,null,null,null,null); };

Using CursorLoader with LoaderManager to retrieve images from android apps

谁说我不能喝 提交于 2019-11-28 14:08:52
At the moment I’m using getContentResolver().query()/managedQuery() to get a cursor to retrieve images from the gallery app. Because the APIs I’m using are partly deprecated I wanted to use CursorLoader with LoaderManager. /** * Creates a cursor to access the content defined by the image uri for API * version 11 and newer. * * @return The created cursor. */ @TargetApi(Build.VERSION_CODES.HONEYCOMB) private Cursor createCursorHoneycomb() { String[] projection = { MediaStore.Images.Media.DATA }; Cursor cursor = getContentResolver().query(imageUri, projection, null, null, null); return cursor; }

Difference between `initLoader` and `restartLoader` in `LoaderManager`

拈花ヽ惹草 提交于 2019-11-28 13:13:04
问题 I'm completely lost regarding the differences between the initLoader and the restartLoader functions of the LoaderManager : They both have the same signature. restartLoader also creates a loader, if it does not exist ("Starts a new or restarts an existing Loader in this manager"). Is there some relation between the two methods? Does calling restartLoader always call initLoader ? Can I call restartLoader without having to call initLoader ? Is it save to call initLoader twice to refresh the

How to get LoaderManager in a ListActivity

与世无争的帅哥 提交于 2019-11-28 11:36:23
问题 I am using compatibility package for implementing CursorLoader in API level < 11 As per the doc and this answer and this wonderful tutorial, I have imported the support packages and implemented the LoaderManager.LoaderCallbacks, but next I have to call: getSupportLoaderManager() and for that one has to extend FragmentActivity, and then call from Activity Context, but I have already extended ListActivity, and want to make a static call to get LoaderManager, like this: FragmentActivity