当前位置: 首页>>代码示例>>Java>>正文


Java AsyncQueryHandler.startQuery方法代码示例

本文整理汇总了Java中android.content.AsyncQueryHandler.startQuery方法的典型用法代码示例。如果您正苦于以下问题:Java AsyncQueryHandler.startQuery方法的具体用法?Java AsyncQueryHandler.startQuery怎么用?Java AsyncQueryHandler.startQuery使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在android.content.AsyncQueryHandler的用法示例。


在下文中一共展示了AsyncQueryHandler.startQuery方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: startQueryHaveLockedMessages

import android.content.AsyncQueryHandler; //导入方法依赖的package包/类
/**
 * Check for locked messages in all threads or a specified thread.
 *
 * @param handler   An AsyncQueryHandler that will receive onQueryComplete
 *                  upon completion of looking for locked messages
 * @param threadIds A list of threads to search. null means all threads
 * @param token     The token that will be passed to onQueryComplete
 */
public static void startQueryHaveLockedMessages(AsyncQueryHandler handler,
                                                Collection<Long> threadIds,
                                                int token) {
    handler.cancelOperation(token);
    Uri uri = MmsSms.CONTENT_LOCKED_URI;

    String selection = null;
    if (threadIds != null) {
        StringBuilder buf = new StringBuilder();
        int i = 0;

        for (long threadId : threadIds) {
            if (i++ > 0) {
                buf.append(" OR ");
            }
            // We have to build the selection arg into the selection because deep down in
            // provider, the function buildUnionSubQuery takes selectionArgs, but ignores it.
            buf.append(Mms.THREAD_ID).append("=").append(Long.toString(threadId));
        }
        selection = buf.toString();
    }
    handler.startQuery(token, threadIds, uri,
            ALL_THREADS_PROJECTION, selection, null, Conversations.DEFAULT_SORT_ORDER);
}
 
开发者ID:moezbhatti,项目名称:qksms,代码行数:33,代码来源:Conversation.java

示例2: queryAsync

import android.content.AsyncQueryHandler; //导入方法依赖的package包/类
/**
 * Queries the defined projection, selection and sort order on a background thread
 * on the given URI through the ContentResolver retrieved from the given context.<br />
 * <br />
 * The callback is called on the thread that called this method when the query finishes.
 * @param context
 * @param uri
 * @param callback
 */
public void queryAsync( Context context, Uri uri, final AsyncQueryCallback callback ) {
	validateForQuery();
	AsyncQueryHandler aqh = new AsyncQueryHandler( context.getContentResolver() ) {
		@Override
		protected void onQueryComplete(int token, Object cookie, Cursor cursor) {
			callback.queryCompleted(cursor);
			if ( !cursor.isClosed() ) {
				cursor.close();
			}
		}
		
	};
	
	Pair<String, String[]> builtSelection = buildSelection();
	aqh.startQuery(0,
				   null,
				   uri,
				   projection,
				   builtSelection.first,
				   builtSelection.second,
				   sortOrder );
}
 
开发者ID:dklisiaris,项目名称:downtown,代码行数:32,代码来源:QueryBuilder.java

示例3: getQueryCursor

import android.content.AsyncQueryHandler; //导入方法依赖的package包/类
private Cursor getQueryCursor(AsyncQueryHandler async, String filter) {
    if (filter == null) {
        filter = "";
    }
    String[] ccols = new String[] {
            BaseColumns._ID, Audio.Media.MIME_TYPE, Audio.Artists.ARTIST, Audio.Albums.ALBUM,
            Audio.Media.TITLE, "data1", "data2"
    };

    Uri search = Uri.parse("content://media/external/audio/search/fancy/" + Uri.encode(filter));

    Cursor ret = null;
    if (async != null) {
        async.startQuery(0, null, search, ccols, null, null, null);
    } else {
        ret = MusicUtils.query(this, search, ccols, null, null, null);
    }
    return ret;
}
 
开发者ID:cpoopc,项目名称:com.cp.monsterMod,代码行数:20,代码来源:QueryBrowserActivity.java

示例4: getQueryCursor

import android.content.AsyncQueryHandler; //导入方法依赖的package包/类
private Cursor getQueryCursor(AsyncQueryHandler async, String filter) {
    if (filter == null) {
        filter = "";
    }
    String[] ccols = new String[] {
            BaseColumns._ID,   // this will be the artist, album or track ID
            MediaStore.Audio.Media.MIME_TYPE, // mimetype of audio file, or "artist" or "album"
            MediaStore.Audio.Artists.ARTIST,
            MediaStore.Audio.Albums.ALBUM,
            MediaStore.Audio.Media.TITLE,
            "data1",
            "data2"
    };

    Uri search = Uri.parse("content://media/external/audio/search/fancy/" +
            Uri.encode(filter));
    
    Cursor ret = null;
    if (async != null) {
        async.startQuery(0, null, search, ccols, null, null, null);
    } else {
        ret = MusicUtils.query(this, search, ccols, null, null, null);
    }
    return ret;
}
 
开发者ID:AndroidLearnerchn,项目名称:Android-Application-Using-CAF-Library,代码行数:26,代码来源:QueryBrowserActivity.java

示例5: getArtistCursor

import android.content.AsyncQueryHandler; //导入方法依赖的package包/类
private Cursor getArtistCursor(AsyncQueryHandler async, String filter) {

        String[] cols = new String[] {
                MediaStore.Audio.Artists._ID,
                MediaStore.Audio.Artists.ARTIST,
                MediaStore.Audio.Artists.NUMBER_OF_ALBUMS,
                MediaStore.Audio.Artists.NUMBER_OF_TRACKS
        };

        Uri uri = MediaStore.Audio.Artists.EXTERNAL_CONTENT_URI;
        if (!TextUtils.isEmpty(filter)) {
            uri = uri.buildUpon().appendQueryParameter("filter", Uri.encode(filter)).build();
        }

        Cursor ret = null;
        if (async != null) {
            async.startQuery(0, null, uri,
                    cols, null , null, MediaStore.Audio.Artists.ARTIST_KEY);
        } else {
            ret = MusicUtils.query(this, uri,
                    cols, null , null, MediaStore.Audio.Artists.ARTIST_KEY);
        }
        return ret;
    }
 
开发者ID:AndroidLearnerchn,项目名称:Android-Application-Using-CAF-Library,代码行数:25,代码来源:ArtistAlbumBrowserActivity.java

示例6: startQueryHaveLockedMessages

import android.content.AsyncQueryHandler; //导入方法依赖的package包/类
/**
 * Check for locked messages in all threads or a specified thread.
 * @param handler An AsyncQueryHandler that will receive onQueryComplete
 *                upon completion of looking for locked messages
 * @param threadIds   A list of threads to search. null means all threads
 * @param token   The token that will be passed to onQueryComplete
 */
public static void startQueryHaveLockedMessages(AsyncQueryHandler handler,
        Collection<Long> threadIds,
        int token) {
    handler.cancelOperation(token);
    Uri uri = MmsSms.CONTENT_LOCKED_URI;

    String selection = null;
    if (threadIds != null) {
        StringBuilder buf = new StringBuilder();
        int i = 0;

        for (long threadId : threadIds) {
            if (i++ > 0) {
                buf.append(" OR ");
            }
            // We have to build the selection arg into the selection because deep down in
            // provider, the function buildUnionSubQuery takes selectionArgs, but ignores it.
            buf.append(Mms.THREAD_ID).append("=").append(Long.toString(threadId));
        }
        selection = buf.toString();
    }
    handler.startQuery(token, threadIds, uri,
            ALL_THREADS_PROJECTION, selection, null, Conversations.DEFAULT_SORT_ORDER);
}
 
开发者ID:slvn,项目名称:android-aosp-mms,代码行数:32,代码来源:Conversation.java

示例7: getPlaylistCursor

import android.content.AsyncQueryHandler; //导入方法依赖的package包/类
public static Cursor getPlaylistCursor(AsyncQueryHandler async,
                                       String filterstring, Context context) {

    StringBuilder where = new StringBuilder();
    where.append(MediaStore.Audio.Playlists.NAME + " != ''");

    // Add in the filtering constraints
    String[] keywords = null;
    if (filterstring != null) {
        String[] searchWords = filterstring.split(" ");
        keywords = new String[searchWords.length];
        Collator col = Collator.getInstance();
        col.setStrength(Collator.PRIMARY);
        for (int i = 0; i < searchWords.length; i++) {
            keywords[i] = '%' + searchWords[i] + '%';
        }
        for (int i = 0; i < searchWords.length; i++) {
            where.append(" AND ");
            where.append(MediaStore.Audio.Playlists.NAME + " LIKE ?");
        }
    }

    String whereclause = where.toString();

    if (async != null) {
        async.startQuery(0, null,
                MediaStore.Audio.Playlists.EXTERNAL_CONTENT_URI, mCols,
                whereclause, keywords, MediaStore.Audio.Playlists.NAME);
        return null;
    }
    Cursor c;
    c = MusicUtils.query(context,
            MediaStore.Audio.Playlists.EXTERNAL_CONTENT_URI, mCols,
            whereclause, keywords, MediaStore.Audio.Playlists.NAME);

    return filterCursor(c);
}
 
开发者ID:89luca89,项目名称:ThunderMusic,代码行数:38,代码来源:PlaylistBrowserActivity.java

示例8: queryAllArtists

import android.content.AsyncQueryHandler; //导入方法依赖的package包/类
public static void queryAllArtists(AsyncQueryHandler queryHandler, int max) {
    String sortOrder = MusicStore.Audio.Artists.DEFAULT_SORT_ORDER + LIMIT + max;
    StringBuilder where = new StringBuilder();
    where.append(MusicStore.Audio.Artists.ARTIST).append(" != ''");
    queryHandler.startQuery( 0, null, MusicStore.Audio.Artists.EXTERNAL_RW_CONTENT_URI,
                ARTIST_COLS, where.toString(), null, sortOrder);
}
 
开发者ID:archos-sa,项目名称:aos-MediaLib,代码行数:8,代码来源:LibraryUtils.java

示例9: startQuery

import android.content.AsyncQueryHandler; //导入方法依赖的package包/类
/**
 * Start a query for in the database on the specified AsyncQueryHandler with the specified
 * "where" clause.
 *
 * @param handler   An AsyncQueryHandler that will receive onQueryComplete
 *                  upon completion of the query
 * @param token     The token that will be passed to onQueryComplete
 * @param selection A where clause (can be null) to select particular conv items.
 */
public static void startQuery(AsyncQueryHandler handler, int token, String selection) {
    handler.cancelOperation(token);

    // This query looks like this in the log:
    // I/Database(  147): elapsedTime4Sql|/data/data/com.android.providers.telephony/databases/
    // mmssms.db|2.253 ms|SELECT _id, date, message_count, recipient_ids, snippet, snippet_cs,
    // read, error, has_attachment FROM threads ORDER BY  date DESC

    handler.startQuery(token, null, sAllThreadsUri,
            ALL_THREADS_PROJECTION, selection, null, Conversations.DEFAULT_SORT_ORDER);
}
 
开发者ID:moezbhatti,项目名称:qksms,代码行数:21,代码来源:Conversation.java

示例10: startQuery

import android.content.AsyncQueryHandler; //导入方法依赖的package包/类
public static void startQuery(AsyncQueryHandler handler, int token, long threadId) {
    // cancel previous operations
    handler.cancelOperation(token);
    handler.startQuery(token, null,
            ContentUris.withAppendedId(Conversations.CONTENT_URI, threadId),
            MESSAGE_LIST_PROJECTION, null, null, Messages.DEFAULT_SORT_ORDER);
}
 
开发者ID:kontalk,项目名称:androidclient,代码行数:8,代码来源:LegacyAbstractMessage.java

示例11: startQuery

import android.content.AsyncQueryHandler; //导入方法依赖的package包/类
public static void startQuery(AsyncQueryHandler handler, int token, long threadId, long count, long lastId) {
    Uri.Builder builder = ContentUris.withAppendedId(Conversations.CONTENT_URI, threadId)
        .buildUpon()
        .appendQueryParameter("count", String.valueOf(count));
    if (lastId > 0) {
        builder.appendQueryParameter("last", String.valueOf(lastId));
    }

    // cancel previous operations
    handler.cancelOperation(token);
    handler.startQuery(token, lastId > 0 ? "append" : null, builder.build(),
            MESSAGE_LIST_PROJECTION, null, null, Messages.DEFAULT_SORT_ORDER);
}
 
开发者ID:kontalk,项目名称:androidclient,代码行数:14,代码来源:CompositeMessage.java

示例12: startQuery

import android.content.AsyncQueryHandler; //导入方法依赖的package包/类
/**
 * Start a query for in the database on the specified AsyncQueryHandler with
 * the specified "where" clause.
 * 
 * @param handler
 *            An AsyncQueryHandler that will receive onQueryComplete upon
 *            completion of the query
 * @param token
 *            The token that will be passed to onQueryComplete
 * @param selection
 *            A where clause (can be null) to select particular conv items.
 */
public static void startQuery(AsyncQueryHandler handler, int token,
		String selection) {
	handler.cancelOperation(token);

	// This query looks like this in the log:
	// I/Database( 147):
	// elapsedTime4Sql|/data/data/com.android.providers.telephony/databases/
	// mmssms.db|2.253 ms|SELECT _id, date, message_count, recipient_ids,
	// snippet, snippet_cs,
	// read, error, has_attachment FROM threads ORDER BY date DESC

	handler.startQuery(token, null, sAllThreadsUri, ALL_THREADS_PROJECTION,
			selection, null, Conversations.DEFAULT_SORT_ORDER);
}
 
开发者ID:CommonQ,项目名称:sms_DualCard,代码行数:27,代码来源:Conversation.java

示例13: startQueryHaveLockedMessages

import android.content.AsyncQueryHandler; //导入方法依赖的package包/类
/**
 * Check for locked messages in all threads or a specified thread.
 * 
 * @param handler
 *            An AsyncQueryHandler that will receive onQueryComplete upon
 *            completion of looking for locked messages
 * @param threadIds
 *            A list of threads to search. null means all threads
 * @param token
 *            The token that will be passed to onQueryComplete
 */
public static void startQueryHaveLockedMessages(AsyncQueryHandler handler,
		Collection<Long> threadIds, int token) {
	handler.cancelOperation(token);
	Uri uri = MmsSms.CONTENT_LOCKED_URI;

	String selection = null;
	if (threadIds != null) {
		StringBuilder buf = new StringBuilder();
		int i = 0;

		for (long threadId : threadIds) {
			if (i++ > 0) {
				buf.append(" OR ");
			}
			// We have to build the selection arg into the selection because
			// deep down in
			// provider, the function buildUnionSubQuery takes
			// selectionArgs, but ignores it.
			buf.append(Mms.THREAD_ID).append("=")
					.append(Long.toString(threadId));
		}
		selection = buf.toString();
	}
	handler.startQuery(token, threadIds, uri, ALL_THREADS_PROJECTION,
			selection, null, Conversations.DEFAULT_SORT_ORDER);
}
 
开发者ID:CommonQ,项目名称:sms_DualCard,代码行数:38,代码来源:Conversation.java

示例14: getPlaylistCursor

import android.content.AsyncQueryHandler; //导入方法依赖的package包/类
private Cursor getPlaylistCursor(AsyncQueryHandler async, String filterstring) {

        StringBuilder where = new StringBuilder();
        where.append(MediaStore.Audio.Playlists.NAME + " != ''");
        
        // Add in the filtering constraints
        String [] keywords = null;
        if (filterstring != null) {
            String [] searchWords = filterstring.split(" ");
            keywords = new String[searchWords.length];
            Collator col = Collator.getInstance();
            col.setStrength(Collator.PRIMARY);
            for (int i = 0; i < searchWords.length; i++) {
                keywords[i] = '%' + searchWords[i] + '%';
            }
            for (int i = 0; i < searchWords.length; i++) {
                where.append(" AND ");
                where.append(MediaStore.Audio.Playlists.NAME + " LIKE ?");
            }
        }
        
        String whereclause = where.toString();
        
        
        if (async != null) {
            async.startQuery(0, null, MediaStore.Audio.Playlists.EXTERNAL_CONTENT_URI,
                    mCols, whereclause, keywords, MediaStore.Audio.Playlists.NAME);
            return null;
        }
        Cursor c = null;
        c = MusicUtils.query(this, MediaStore.Audio.Playlists.EXTERNAL_CONTENT_URI,
                mCols, whereclause, keywords, MediaStore.Audio.Playlists.NAME);
        
        return mergedCursor(c);
    }
 
开发者ID:AndroidLearnerchn,项目名称:Android-Application-Using-CAF-Library,代码行数:36,代码来源:PlaylistBrowserActivity.java

示例15: startQuery

import android.content.AsyncQueryHandler; //导入方法依赖的package包/类
/**
 * Start a query for in the database on the specified AsyncQueryHandler with the specified
 * "where" clause.
 *
 * @param handler An AsyncQueryHandler that will receive onQueryComplete
 *                upon completion of the query
 * @param token   The token that will be passed to onQueryComplete
 * @param selection   A where clause (can be null) to select particular conv items.
 */
public static void startQuery(AsyncQueryHandler handler, int token, String selection) {
    handler.cancelOperation(token);

    // This query looks like this in the log:
    // I/Database(  147): elapsedTime4Sql|/data/data/com.android.providers.telephony/databases/
    // mmssms.db|2.253 ms|SELECT _id, date, message_count, recipient_ids, snippet, snippet_cs,
    // read, error, has_attachment FROM threads ORDER BY  date DESC

    handler.startQuery(token, null, sAllThreadsUri,
            ALL_THREADS_PROJECTION, selection, null, Conversations.DEFAULT_SORT_ORDER);
}
 
开发者ID:slvn,项目名称:android-aosp-mms,代码行数:21,代码来源:Conversation.java


注:本文中的android.content.AsyncQueryHandler.startQuery方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。