调用getLoaderManager()。restartLoader()时有关AsyncTasks的红色(错误?)logcat消息

时间:2014-09-10 04:06:20

标签: android android-asynctask android-loadermanager

我的应用有一个自定义键盘,其中包含ListView中显示的自定义用户词典输入建议。我刚刚完成重写,以便它使用SimpleCursorAdapterContentProviderLoaderManager。有时,我会使用自定义SimpleCursorAdapter更换ListView中的ArrayAdapter,以便提供其他建议。我使用AsyncTask来获取ArrayAdapter数组的数据。

调用getLoaderManager().restartLoader(WORDS_LOADER_ID, bundle, this);时,Eclipse中的LogCat会以红色文本显示一些消息。基本上每次按键都会调用restartLoader语句,因为我需要重新查询字典数据库。以下是消息:

09-10 11:44:50.058: E/dalvikvm(13875): threadid=11: created from interp,name=AsyncTask #1
09-10 11:44:50.068: E/dalvikvm(13875): threadid=11: calling run(),name=AsyncTask #1
09-10 11:44:53.542: E/dalvikvm(13875): threadid=12: created from interp,name=AsyncTask #2
09-10 11:44:53.542: E/dalvikvm(13875): threadid=12: calling run(),name=AsyncTask #2
09-10 11:45:01.630: E/dalvikvm(13875): threadid=13: created from interp,name=AsyncTask #3
09-10 11:45:01.640: E/dalvikvm(13875): threadid=13: calling run(),name=AsyncTask #3
09-10 11:45:02.832: E/dalvikvm(13875): threadid=14: created from interp,name=AsyncTask #4
09-10 11:45:02.842: E/dalvikvm(13875): threadid=14: calling run(),name=AsyncTask #4
09-10 11:45:06.365: E/dalvikvm(13875): threadid=15: created from interp,name=AsyncTask #5
09-10 11:45:06.375: E/dalvikvm(13875): threadid=15: calling run(),name=AsyncTask #5

到达name=AsyncTask #5后,即使我继续按其他键,也不会再显示红色消息。

关键问题:应用程序本身似乎一切正常,没有抛出任何异常,但红色意味着错误,对吗?有什么我应该担心的吗?

我阅读了LoaderManager documentationHow to Use Loaders in Android,据我所知,我已正确设置了内容。当然有其他人遇到过这个,但我无法找到任何东西。

片段实现LoaderManager.LoaderCallbacks<Cursor>,这里是重写的方法:

@Override
public Loader<Cursor> onCreateLoader(int loaderID, Bundle bundle) {

    String[] projection;
    String selection;
    String[] selectionArgs = { "" };
    String orderBy;

    switch (loaderID) {
    case WORDS_LOADER_ID:

        projection = new String[] { MyUserDictionary.Words._ID,
                MyUserDictionary.Words.WORD,
                MyUserDictionary.Words.FREQUENCY,
                MyUserDictionary.Words.FOLLOWING };
        selection = MyUserDictionary.Words.WORD + " LIKE ?";
        selectionArgs[0] = bundle.getString("query") + "%";
        orderBy = MyUserDictionary.Words.DEFAULT_SORT_ORDER;

        return new CursorLoader(getActivity().getApplicationContext(),
                MyUserDictionary.Words.CONTENT_URI, projection,
                selection, selectionArgs, orderBy);

    default:
        Log.e("MyApp", "An invalid id was passed in");
        return null;
    }
}

@Override
public void onLoadFinished(Loader<Cursor> arg0, Cursor newCursor) {
    cursorAdapter.swapCursor(newCursor);
}

@Override
public void onLoaderReset(Loader<Cursor> arg0) {
    cursorAdapter.swapCursor(null);
}

0 个答案:

没有答案