當前位置: 首頁>>代碼示例>>Java>>正文


Java Contacts.getLookupUri方法代碼示例

本文整理匯總了Java中android.provider.ContactsContract.Contacts.getLookupUri方法的典型用法代碼示例。如果您正苦於以下問題:Java Contacts.getLookupUri方法的具體用法?Java Contacts.getLookupUri怎麽用?Java Contacts.getLookupUri使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在android.provider.ContactsContract.Contacts的用法示例。


在下文中一共展示了Contacts.getLookupUri方法的13個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: getContactUriForNumber

import android.provider.ContactsContract.Contacts; //導入方法依賴的package包/類
private Uri getContactUriForNumber(String number) {
  String[] PROJECTION = new String[] {
    PhoneLookup.DISPLAY_NAME,
    PhoneLookup.LOOKUP_KEY,
    PhoneLookup._ID,
  };

  Uri uri       = Uri.withAppendedPath(PhoneLookup.CONTENT_FILTER_URI, Uri.encode(number));
  Cursor cursor = null;

  try {
    cursor = context.getContentResolver().query(uri, PROJECTION, null, null, null);

    if (cursor != null && cursor.moveToFirst()) {
      return Contacts.getLookupUri(cursor.getLong(2), cursor.getString(1));
    }
  } finally {
    if (cursor != null)
      cursor.close();
  }

  return null;
}
 
開發者ID:XecureIT,項目名稱:PeSanKita-android,代碼行數:24,代碼來源:ContactIdentityManagerGingerbread.java

示例2: getRecipientDetails

import android.provider.ContactsContract.Contacts; //導入方法依賴的package包/類
private RecipientDetails getRecipientDetails(Context context, String number) {
  Uri uri       = Uri.withAppendedPath(PhoneLookup.CONTENT_FILTER_URI, Uri.encode(number));
  Cursor cursor = context.getContentResolver().query(uri, CALLER_ID_PROJECTION,
                                                     null, null, null);

  try {
    if (cursor != null && cursor.moveToFirst()) {
      Uri      contactUri   = Contacts.getLookupUri(cursor.getLong(2), cursor.getString(1));
      String   name         = cursor.getString(3).equals(cursor.getString(0)) ? null : cursor.getString(0);
      Drawable contactPhoto = ContactPhotoFactory.getContactPhoto(context,
                                                                  Uri.withAppendedPath(Contacts.CONTENT_URI, cursor.getLong(2) + ""),
                                                                  name);
      return new RecipientDetails(cursor.getString(0), cursor.getString(3), contactUri, contactPhoto);
    }
  } finally {
    if (cursor != null)
      cursor.close();
  }

  return new RecipientDetails(null, number, null, ContactPhotoFactory.getDefaultContactPhoto(context, null));
}
 
開發者ID:Agilitum,項目名稱:TextSecureSMP,代碼行數:22,代碼來源:RecipientProvider.java

示例3: showContact

import android.provider.ContactsContract.Contacts; //導入方法依賴的package包/類
@TargetApi(VERSION_CODES.ICE_CREAM_SANDWICH)
private void showContact(long id) {
  GlideRequests glideRequests = GlideApp.with(this);
  RequestOptions originalSize = new RequestOptions().override(Target.SIZE_ORIGINAL);

  Uri contactUri = ContentUris.withAppendedId(Contacts.CONTENT_URI, id);
  glideRequests.load(contactUri).apply(originalSize).into(imageViewContact);

  Uri lookupUri = Contacts.getLookupUri(getContentResolver(), contactUri);
  glideRequests.load(lookupUri).apply(originalSize).into(imageViewLookup);

  Uri photoUri = Uri.withAppendedPath(contactUri, Contacts.Photo.CONTENT_DIRECTORY);
  glideRequests.load(photoUri).apply(originalSize).into(imageViewPhoto);

  if (VERSION.SDK_INT >= VERSION_CODES.ICE_CREAM_SANDWICH) {
    Uri displayPhotoUri = Uri.withAppendedPath(contactUri, Contacts.Photo.DISPLAY_PHOTO);
    glideRequests.load(displayPhotoUri).apply(originalSize).into(imageViewDisplayPhoto);
  }
}
 
開發者ID:weiwenqiang,項目名稱:GitHub,代碼行數:20,代碼來源:MainActivity.java

示例4: getSelfIdentityUri

import android.provider.ContactsContract.Contacts; //導入方法依賴的package包/類
@SuppressLint("NewApi")
@Override
public Uri getSelfIdentityUri() {
  String[] PROJECTION = new String[] {
      PhoneLookup.DISPLAY_NAME,
      PhoneLookup.LOOKUP_KEY,
      PhoneLookup._ID,
  };

  Cursor cursor = null;

  try {
    cursor = context.getContentResolver().query(ContactsContract.Profile.CONTENT_URI,
                                                  PROJECTION, null, null, null);

    if (cursor != null && cursor.moveToFirst()) {
      return Contacts.getLookupUri(cursor.getLong(2), cursor.getString(1));
    }
  } finally {
    if (cursor != null)
      cursor.close();
  }

  return null;
}
 
開發者ID:XecureIT,項目名稱:PeSanKita-android,代碼行數:26,代碼來源:ContactIdentityManagerICS.java

示例5: getRecipientDetails

import android.provider.ContactsContract.Contacts; //導入方法依賴的package包/類
private RecipientDetails getRecipientDetails(Context context, String number) {
  Uri uri       = Uri.withAppendedPath(PhoneLookup.CONTENT_FILTER_URI, Uri.encode(number));
  Cursor cursor = context.getContentResolver().query(uri, CALLER_ID_PROJECTION,
                                                     null, null, null);

  try {
    if (cursor != null && cursor.moveToFirst()) {
      Uri contactUri      = Contacts.getLookupUri(cursor.getLong(2), cursor.getString(1));
      Bitmap contactPhoto = ContactPhotoFactory.getContactPhoto(context, Uri.withAppendedPath(Contacts.CONTENT_URI,
                                                                                              cursor.getLong(2)+""));
      return new RecipientDetails(cursor.getString(0), cursor.getString(3), contactUri, contactPhoto,
                                  BitmapUtil.getCircleCroppedBitmap(contactPhoto));
    }
  } finally {
    if (cursor != null)
      cursor.close();
  }

  return null;
}
 
開發者ID:redcracker,項目名稱:TextSecure,代碼行數:21,代碼來源:RecipientProvider.java

示例6: onItemClick

import android.provider.ContactsContract.Contacts; //導入方法依賴的package包/類
@Override
public void onItemClick(AdapterView<?> parent, View v, int position, long id) {
    // Gets the Cursor object currently bound to the ListView
    final Cursor cursor = mAdapter.getCursor();

    // Moves to the Cursor row corresponding to the ListView item that was clicked
    cursor.moveToPosition(position);

    // Creates a contact lookup Uri from contact ID and lookup_key
    final Uri uri = Contacts.getLookupUri(
            cursor.getLong(ContactsQuery.ID),
            cursor.getString(ContactsQuery.LOOKUP_KEY));

    // Notifies the parent activity that the user selected a contact. In a two-pane layout, the
    // parent activity loads a ContactDetailFragment that displays the details for the selected
    // contact. In a single-pane layout, the parent activity starts a new activity that
    // displays contact details in its own Fragment.
    mOnContactSelectedListener.onContactSelected(uri);

    // If two-pane layout sets the selected item to checked so it remains highlighted. In a
    // single-pane layout a new activity is started so this is not needed.
    if (mIsTwoPaneLayout) {
        getListView().setItemChecked(position, true);
    }
}
 
開發者ID:aarya123,項目名稱:CampusFeedv2,代碼行數:26,代碼來源:ContactsListFragment.java

示例7: getContactLookupUri

import android.provider.ContactsContract.Contacts; //導入方法依賴的package包/類
@Nullable
public Uri getContactLookupUri() {
    if (contactId == null) {
        return null;
    }

    return Contacts.getLookupUri(contactId, contactLookupKey);
}
 
開發者ID:philipwhiuk,項目名稱:q-mail,代碼行數:9,代碼來源:RecipientSelectView.java

示例8: getIndividualRecipientDetails

import android.provider.ContactsContract.Contacts; //導入方法依賴的package包/類
private @NonNull RecipientDetails getIndividualRecipientDetails(Context context, long recipientId, @NonNull String number) {
  Optional<RecipientsPreferences> preferences = DatabaseFactory.getRecipientPreferenceDatabase(context).getRecipientsPreferences(new long[]{recipientId});
  MaterialColor                   color       = preferences.isPresent() ? preferences.get().getColor() : null;
  Uri                             uri         = Uri.withAppendedPath(PhoneLookup.CONTENT_FILTER_URI, Uri.encode(number));
  Cursor                          cursor      = context.getContentResolver().query(uri, CALLER_ID_PROJECTION,
                                                                                   null, null, null);

  try {
    if (cursor != null && cursor.moveToFirst()) {
      final String resultNumber = cursor.getString(3);
      if (resultNumber != null) {
        Uri          contactUri   = Contacts.getLookupUri(cursor.getLong(2), cursor.getString(1));
        String       name         = resultNumber.equals(cursor.getString(0)) ? null : cursor.getString(0);
        ContactPhoto contactPhoto = ContactPhotoFactory.getContactPhoto(context,
                                                                        Uri.withAppendedPath(Contacts.CONTENT_URI, cursor.getLong(2) + ""),
                                                                        name);

        return new RecipientDetails(cursor.getString(0), resultNumber, contactUri, contactPhoto, color);
      } else {
        Log.w(TAG, "resultNumber is null");
      }
    }
  } finally {
    if (cursor != null)
      cursor.close();
  }

  if (STATIC_DETAILS.containsKey(number)) return STATIC_DETAILS.get(number);
  else                                    return new RecipientDetails(null, number, null, ContactPhotoFactory.getDefaultContactPhoto(null), color);
}
 
開發者ID:XecureIT,項目名稱:PeSanKita-android,代碼行數:31,代碼來源:RecipientProvider.java

示例9: getIndividualRecipientDetails

import android.provider.ContactsContract.Contacts; //導入方法依賴的package包/類
private @NonNull RecipientDetails getIndividualRecipientDetails(Context context, long recipientId, @NonNull String number) {
  Optional<RecipientsPreferences> preferences = DatabaseFactory.getRecipientPreferenceDatabase(context).getRecipientsPreferences(new long[]{recipientId});
  MaterialColor                   color       = preferences.isPresent() ? preferences.get().getColor() : null;
  Uri                             uri         = Uri.withAppendedPath(PhoneLookup.CONTENT_FILTER_URI, Uri.encode(number));
  Cursor                          cursor      = context.getContentResolver().query(uri, CALLER_ID_PROJECTION,
                                                                                   null, null, null);

  try {
    if (cursor != null && cursor.moveToFirst()) {
      final String resultNumber = cursor.getString(3);
      if (resultNumber != null) {
        Uri          contactUri   = Contacts.getLookupUri(cursor.getLong(2), cursor.getString(1));
        String       name         = resultNumber.equals(cursor.getString(0)) ? null : cursor.getString(0);
        ContactPhoto contactPhoto = ContactPhotoFactory.getContactPhoto(context,
                                                                        Uri.withAppendedPath(Contacts.CONTENT_URI, cursor.getLong(2) + ""),
                                                                        name);

        return new RecipientDetails(cursor.getString(0), resultNumber, cursor.getString(4), contactUri, contactPhoto, color);
      } else {
        Log.w(TAG, "resultNumber is null");
      }
    }
  } finally {
    if (cursor != null)
      cursor.close();
  }

  if (STATIC_DETAILS.containsKey(number)) return STATIC_DETAILS.get(number);
  else                                    return new RecipientDetails(null, number, null, null, ContactPhotoFactory.getDefaultContactPhoto(null), color);
}
 
開發者ID:CableIM,項目名稱:Cable-Android,代碼行數:31,代碼來源:RecipientProvider.java

示例10: onItemClick

import android.provider.ContactsContract.Contacts; //導入方法依賴的package包/類
@Override
public void onItemClick(AdapterView<?> parent, View v, int position, long id) {
    // Gets the Cursor object currently bound to the ListView
    final Cursor cursor = mAdapter.getCursor();

    // Moves to the Cursor row corresponding to the ListView item that was clicked
    cursor.moveToPosition(position);

    // Creates a contact lookup Uri from contact ID and lookup_key
    final Uri uri = Contacts.getLookupUri(
            cursor.getLong(ContactsQuery.ID),
            cursor.getString(ContactsQuery.LOOKUP_KEY));

    mOnContactSelectedListener.onContactSelected(uri);
}
 
開發者ID:AppLozic,項目名稱:Applozic-Android-Chat-Sample,代碼行數:16,代碼來源:ContactsListFragment.java

示例11: onQueryComplete

import android.provider.ContactsContract.Contacts; //導入方法依賴的package包/類
@Override
protected void onQueryComplete(int token, Object cookie, Cursor cursor) {
    Uri lookupUri = null;
    Uri createUri = null;
    boolean trigger = false;
    Bundle extras = (cookie != null) ? (Bundle) cookie : new Bundle();
    try {
        switch (token) {
            case TOKEN_EMAIL_LOOKUP_AND_TRIGGER:
                trigger = true;
                createUri = Uri.fromParts("mailto",
                        extras.getString(EXTRA_URI_CONTENT), null);

                //$FALL-THROUGH$
            case TOKEN_EMAIL_LOOKUP: {
                if (cursor != null && cursor.moveToFirst()) {
                    long contactId = cursor.getLong(EMAIL_ID_COLUMN_INDEX);
                    String lookupKey = cursor.getString(EMAIL_LOOKUP_STRING_COLUMN_INDEX);
                    lookupUri = Contacts.getLookupUri(contactId, lookupKey);
                }
                break;
            }
        }
    } finally {
        if (cursor != null) {
            cursor.close();
        }
    }

    contactUri = lookupUri;
    onContactUriChanged();

    if (trigger && lookupUri != null) {
        // Found contact, so trigger QuickContact
        QuickContact.showQuickContact(
                getContext(), ContactBadge.this, lookupUri, QuickContact.MODE_LARGE, null);
    } else if (createUri != null) {
        // Prompt user to add this person to contacts
        final Intent intent = new Intent(Intents.SHOW_OR_CREATE_CONTACT, createUri);
        extras.remove(EXTRA_URI_CONTENT);
        intent.putExtras(extras);
        getContext().startActivity(intent);
    }
}
 
開發者ID:philipwhiuk,項目名稱:q-mail,代碼行數:45,代碼來源:ContactBadge.java

示例12: bindView

import android.provider.ContactsContract.Contacts; //導入方法依賴的package包/類
/**
         * Binds data from the Cursor to the provided view.
         */
        @Override
        public void bindView(View view, Context context, Cursor cursor) {
            // Gets handles to individual view resources
            final ViewHolder holder = (ViewHolder) view.getTag();
/*
           if (holder.text1 == null) {
        	   holder.text1 = (TextView) view.findViewById(android.R.id.text1);
               holder.text2 = (TextView) view.findViewById(android.R.id.text2);
               holder.icon = (QuickContactBadge) view.findViewById(android.R.id.icon);
           }*/
            	//return;

            // For Android 3.0 and later, gets the thumbnail image Uri from the current Cursor row.
            // For platforms earlier than 3.0, this isn't necessary, because the thumbnail is
            // generated from the other fields in the row.
            final String photoUri = cursor.getString(ContactsQuery.PHOTO_THUMBNAIL_DATA);

            final String displayName = cursor.getString(ContactsQuery.DISPLAY_NAME);
            
            final int startIndex = indexOfSearchQuery(displayName);

            if (startIndex == -1) {
                // If the user didn't do a search, or the search string didn't match a display
                // name, show the display name without highlighting
                holder.text1.setText(displayName);

                if (TextUtils.isEmpty(mSearchTerm)) {
                    // If the search search is empty, hide the second line of text
                    holder.text2.setVisibility(View.GONE);
                } else {
                    // Shows a second line of text that indicates the search string matched
                    // something other than the display name
                    holder.text2.setVisibility(View.VISIBLE);
                }
            } else {
                // If the search string matched the display name, applies a SpannableString to
                // highlight the search string with the displayed display name

                // Wraps the display name in the SpannableString
                final SpannableString highlightedName = new SpannableString(displayName);

                // Sets the span to start at the starting point of the match and end at "length"
                // characters beyond the starting point
                highlightedName.setSpan(highlightTextSpan, startIndex,
                        startIndex + mSearchTerm.length(), 0);

                // Binds the SpannableString to the display name View object
                holder.text1.setText(highlightedName);

                // Since the search string matched the name, this hides the secondary message
                holder.text2.setVisibility(View.GONE);
            }

            // Processes the QuickContactBadge. A QuickContactBadge first appears as a contact's
            // thumbnail image with styling that indicates it can be touched for additional
            // information. When the user clicks the image, the badge expands into a dialog box
            // containing the contact's details and icons for the built-in apps that can handle
            // each detail type.

            // Generates the contact lookup Uri
            final Uri contactUri = Contacts.getLookupUri(
                    cursor.getLong(ContactsQuery.ID),
                    cursor.getString(ContactsQuery.LOOKUP_KEY));

            // Binds the contact's lookup Uri to the QuickContactBadge
            holder.icon.assignContactUri(contactUri);

            // Loads the thumbnail image pointed to by photoUri into the QuickContactBadge in a
            // background worker thread
            mImageLoader.loadImage(photoUri, holder.icon);
        }
 
開發者ID:aarya123,項目名稱:CampusFeedv2,代碼行數:75,代碼來源:ContactsListFragment.java

示例13: getLookupURI

import android.provider.ContactsContract.Contacts; //導入方法依賴的package包/類
@Override
public Uri getLookupURI( Cursor cursor ) {
	long id = CursorUtils.getLong( cursor, BaseColumns._ID );
	String lookupKey = CursorUtils.getString( cursor, Contacts.LOOKUP_KEY );
	return Contacts.getLookupUri( id, lookupKey );
}
 
開發者ID:SilentCircle,項目名稱:silent-text-android,代碼行數:7,代碼來源:SystemContactsEmailCriteria.java


注:本文中的android.provider.ContactsContract.Contacts.getLookupUri方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。