在获取memo的时候有一个根据Uri
获取Cursor的方法是用的Activity的方法:mCursor = managedQuery(mUri, PROJECTION, null, null, null);
This method is deprecated.
Use CursorLoader
instead.
Wrapper around query(android.net.Uri, String[], String, String[], String)
that gives the resulting Cursor
to call startManagingCursor(Cursor)
so that the activity will manage its lifecycle for you. If you are targeting HONEYCOMB
or later, consider instead using LoaderManager
instead, available via getLoaderManager()
.
uri | The URI of the content provider to query. |
---|---|
projection | List of columns to return. |
selection | SQL WHERE clause. |
selectionArgs | The arguments to selection, if any ?s are pesent |
sortOrder | SQL ORDER BY clause. |
query(android.net.Uri, String[], String, String[], String)
startManagingCursor(Cursor)
E/AndroidRuntime( 1051): java.lang.RuntimeException: Unable to resume activity {com.lenovo.leos.memowidget/com.lenovo.leos.notepad.NoteEditor}: java.lang.IllegalStateException: trying to requery an already closed cursor
E/AndroidRuntime( 1051): at android.app.ActivityThread.performResumeActivity(ActivityThread.java:2227)
E/AndroidRuntime( 1051): at android.app.ActivityThread.handleResumeActivity(ActivityThread.java:2255)
E/AndroidRuntime( 1051): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1028)
E/AndroidRuntime( 1051): at android.os.Handler.dispatchMessage(Handler.java:99)
E/AndroidRuntime( 1051): at android.os.Looper.loop(Looper.java:132)
E/AndroidRuntime( 1051): at android.app.ActivityThread.main(ActivityThread.java:4025)
E/AndroidRuntime( 1051): at java.lang.reflect.Method.invokeNative(Native Method)
E/AndroidRuntime( 1051): at java.lang.reflect.Method.invoke(Method.java:491)
E/AndroidRuntime( 1051): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:847)
E/AndroidRuntime( 1051): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:605)
E/AndroidRuntime( 1051): at dalvik.system.NativeStart.main(Native Method)
E/AndroidRuntime( 1051): Caused by: java.lang.IllegalStateException: trying to requery an already closed cursor
E/AndroidRuntime( 1051): at android.app.Activity.performRestart(Activity.java:4394)
E/AndroidRuntime( 1051): at android.app.Activity.performResume(Activity.java:4420)
E/AndroidRuntime( 1051): at android.app.ActivityThread.performResumeActivity(ActivityThread.java:2217)
E/AndroidRuntime( 1051): ... 10 more
W/ActivityManager( 124): Force finishing activity com.lenovo.leos.memowidget/com.lenovo.leos.notepad.NoteEditor
W/ActivityManager( 124): Activity pause timeout for ActivityRecord{40472ac8 com.lenovo.leos.memowidget/com.lenovo.leos.notepad.NoteEditor}
E/Launcher( 1029): onResume
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
如果使用query则单纯的将Cursor返回来,就不会出现上述异常了。
Query the given URI, returning a Cursor
over the result set.
For best performance, the caller should follow these guidelines:
selection
parameter, so that queries that differ only by those values will be recognized as the same for caching purposes.uri | The URI, using the content:// scheme, for the content to retrieve. |
---|---|
projection | A list of which columns to return. Passing null will return all columns, which is inefficient. |
selection | A filter declaring which rows to return, formatted as an SQL WHERE clause (excluding the WHERE itself). Passing null will return all rows for the given URI. |
selectionArgs | You may include ?s in selection, which will be replaced by the values from selectionArgs, in the order that they appear in the selection. The values will be bound as Strings. |
sortOrder | How to order the rows, formatted as an SQL ORDER BY clause (excluding the ORDER BY itself). Passing null will use the default sort order, which may be unordered. |
Cursor
以上就是如何解决pad记事本的从历史进入memo时出现上述异常的bug了。