Code example for AsyncTask

Methods: cancel, getStatus

0
            mUri = uri;
        } 
 
        @Override 
        public void changeCursor(Cursor c) {
            if (mLoadTask != null && mLoadTask.getStatus() != QueryTask.Status.FINISHED) {
                mLoadTask.cancel(true);
                mLoadTask = null;
            } 
            super.changeCursor(c);
        } 
 
        class QueryTask extends AsyncTask<Void, Void, Cursor> {
            @Override 
            protected Cursor doInBackground(Void... params) {
                if (mContext instanceof Activity) {
                    return ((Activity) mContext).managedQuery(
                            Uri.parse(mUri), mColumns, mSelection, mSelectionArgs, mSortOrder);
                } else { 
                    return mContext.getContentResolver().query(
                            Uri.parse(mUri), mColumns, mSelection, mSelectionArgs, mSortOrder);