我只是在android中尝试Async任务。
它有效,但与该任务对应的线程何时被杀死?
当我在DDMS中检查它时,它仍处于等待状态。
以下是我工作的代码。
ThreadListQueryHandler mQueryHandler = new ThreadListQueryHandler(getContentResolver());
startAsyncQuery();
private void startAsyncQuery()
{
try
{
setTitle("Refreshing");
setProgressBarIndeterminateVisibility(true);
Conversation.startQueryForAll(mQueryHandler,QUERY_THREAD_LIST_ALL);
}
catch (SQLException e) {
Log.e("Event", "Catch a SQLiteException when query: ", e); }
}
public class ThreadListQueryHandler extends AsyncQueryHandler{
public ThreadListQueryHandler(ContentResolver contentresolver) {
super(contentresolver);
}
@Override
protected void onQueryComplete(int token, Object cookie, Cursor cursor) {
setTitle("Complete");
setProgressBarIndeterminateVisibility(false);
cursor.moveToFirst();
switch (token) {
case QUERY_THREAD_LIST_ALL:
Toast.makeText(context,""+cursor.getCount(),Toast.LENGTH_SHORT).show(); break;
}
}