本文整理汇总了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);
}
示例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 );
}
示例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;
}
示例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);
}
示例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);
}
示例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);
}
示例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);
}
示例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);
}
示例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);
}
示例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);
}
示例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);
}
示例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);
}