Most visited

Recently visited

Added in API level 21

ContactsContract.SearchSnippets

public static class ContactsContract.SearchSnippets
extends Object

java.lang.Object
   ↳ android.provider.ContactsContract.SearchSnippets


Contacts.CONTENT_FILTER_URI返回的附加列解释了过滤器匹配联系人的原因。 此列将包含联系人组成部分Data ,格式化的方式表示与过滤器匹配的摘录部分。

以下示例搜索与查询“presi”匹配的所有联系人,并请求代码段列。

 Builder builder = Contacts.CONTENT_FILTER_URI.buildUpon();
 builder.appendPath("presi");
 // Defer snippeting to the client side if possible, for performance reasons.
 builder.appendQueryParameter(SearchSnippets.DEFERRED_SNIPPETING_KEY,"1");

 Cursor cursor = getContentResolver().query(builder.build());

 Bundle extras = cursor.getExtras();
 if (extras.getBoolean(ContactsContract.DEFERRED_SNIPPETING)) {
     // Do our own snippet formatting.
     // For a contact with the email address (president@organization.com), the snippet
     // column will contain the string "president@organization.com".
 } else {
     // The snippet has already been pre-formatted, we can display it as is.
     // For a contact with the email address (president@organization.com), the snippet
     // column will contain the string "[presi]dent@organization.com".
 }
 

Summary

Constants

String DEFERRED_SNIPPETING_KEY

如果可能的话,要求提供者将片段的格式推迟到客户端的关键是出于性能原因。

String SNIPPET

由SQLite snippeting功能构建的搜索片段。

Public constructors

ContactsContract.SearchSnippets()

Inherited methods

From class java.lang.Object

Constants

DEFERRED_SNIPPETING_KEY

Added in API level 21
String DEFERRED_SNIPPETING_KEY

如果可能的话,要求提供者将片段的格式推迟到客户端的关键是出于性能原因。 值1表示true,0表示false。 假是默认的。 当光标返回给客户端时,它应该检查光标中名称为DEFERRED_SNIPPETING的附加信息。 如果存在,客户端应该自己对片段进行格式化。 如果它不存在,则游标中的片段列应该已经包含格式化的片段。

常量值:“deferred_snippeting”

SNIPPET

Added in API level 21
String SNIPPET

由SQLite snippeting功能构建的搜索片段。

片段可以包含属于该联系人的若干数据元素(的一部分),并且匹配部分可以被特殊字符围绕,该特殊字符指示匹配文本的开始和结束。 例如,如果联系人的地址为“123 Main Street”,则使用过滤器“mai”将返回格式化的片段“123 [Mai] n street”。

也可以看看:

常量值:“snippet”

Public constructors

ContactsContract.SearchSnippets

Added in API level 21
ContactsContract.SearchSnippets ()

Hooray!