本文整理匯總了Java中android.provider.ContactsContract.CommonDataKinds.Phone.NUMBER屬性的典型用法代碼示例。如果您正苦於以下問題:Java Phone.NUMBER屬性的具體用法?Java Phone.NUMBER怎麽用?Java Phone.NUMBER使用的例子?那麽, 這裏精選的屬性代碼示例或許可以為您提供幫助。您也可以進一步了解該屬性所在類android.provider.ContactsContract.CommonDataKinds.Phone
的用法示例。
在下文中一共展示了Phone.NUMBER屬性的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: loadUserInfoFromPhone
private void loadUserInfoFromPhone(){
User user = AppManager.getSession();
if (user != null) {
etName.setText(user.getName());
Util.setProfileImage(user.getPhoto(), imgProfile);
} else {
if (checkPermissions()) {
String[] projection = new String[] {
Phone.DISPLAY_NAME,
Phone.HAS_PHONE_NUMBER,
Phone.NUMBER,
Phone.CONTACT_ID};
Cursor cursor = getApplication().getContentResolver().query(ContactsContract.Profile.CONTENT_URI, null, null, null, null);
if (cursor.moveToFirst()){
etName.setText(cursor.getString(cursor.getColumnIndex("display_name")));
}
cursor.close();
}
}
}
示例2: getContactFromPhonebook
/**
* Helper to retrieve a contact's information from the phone book activity
*
* @param data The Intent carrying the data of the phone book selection
* @param context Context to get content resolver from
* @return Contact object storing the name and phone number of the retrieved contact
*/
public static ContactUtils.Contact getContactFromPhonebook(Intent data, Context context) {
// Get the data from the Intent
Uri contact_data = data.getData();
// Query the Intent's data and extract the ID and name of the contact
String[] projection = {Phone.DISPLAY_NAME, Phone.NUMBER};
String sel = String.format("%s = %s", Phone.TYPE, Phone.TYPE_MOBILE);
Cursor c = context.getContentResolver().query(contact_data, projection, sel, null, null);
if (c.moveToFirst()) {
if (c.moveToFirst()) {
String name = c.getString(c.getColumnIndex(Phone.DISPLAY_NAME));
String phone = convertToE164(c.getString(c.getColumnIndex(Phone.NUMBER)));
return new ContactUtils.Contact(name, phone);
}
c.close();
}
return new ContactUtils.Contact();
}
示例3: loadContact2
public static List<ContactEntity> loadContact2(Context context){
List<ContactEntity> contacts=new ArrayList<ContactEntity>();
ContentResolver cr=context.getContentResolver();
String [] projection={Phone.DISPLAY_NAME,Phone.NUMBER,Photo.PHOTO_ID,Phone.CONTACT_ID};
Cursor c=cr.query(Phone.CONTENT_URI, projection, null, null, null);
if(c!=null){
while(c.moveToNext()){
String name=c.getString(0);
String number=c.getString(1);
long contactId=c.getLong(3);
long photoId=c.getLong(2);
Bitmap bitmap=null;
if(photoId>0){
Uri uri=ContentUris.withAppendedId(ContactsContract.Contacts.CONTENT_URI, contactId);
InputStream input=ContactsContract.Contacts.openContactPhotoInputStream(cr, uri);
bitmap=BitmapFactory.decodeStream(input);
}
ContactEntity entity=new ContactEntity();
entity.setName(name);
entity.setNumber(number);
entity.setBitmap(bitmap);
contacts.add(entity);
}
}
c.close();
return contacts;
}
示例4: doInBackground
@Override
protected Void doInBackground(Long... ids) {
String[] projection = new String[] {Phone.DISPLAY_NAME, Phone.TYPE, Phone.NUMBER, Phone.LABEL};
long contactId = ids[0];
final Cursor phoneCursor = getActivity().getContentResolver().query(
Phone.CONTENT_URI,
projection,
Data.CONTACT_ID + "=?",
new String[]{String.valueOf(contactId)},
null);
if(phoneCursor != null && phoneCursor.moveToFirst() && phoneCursor.getCount() == 1) {
final int contactNumberColumnIndex = phoneCursor.getColumnIndex(Phone.NUMBER);
mPhoneNumber = phoneCursor.getString(contactNumberColumnIndex);
int type = phoneCursor.getInt(phoneCursor.getColumnIndexOrThrow(Phone.TYPE));
mPhoneLabel = phoneCursor.getString(phoneCursor.getColumnIndex(Phone.LABEL));
mPhoneLabel = Phone.getTypeLabel(getResources(), type, mPhoneLabel).toString();
phoneCursor.close();
}
return null;
}
示例5: onCreate
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
// Set up our adapter
mAdapter = new MyExpandableListAdapter(
this,
android.R.layout.simple_expandable_list_item_1,
android.R.layout.simple_expandable_list_item_1,
new String[] { Contacts.DISPLAY_NAME }, // Name for group layouts
new int[] { android.R.id.text1 },
new String[] { Phone.NUMBER }, // Number for child layouts
new int[] { android.R.id.text1 });
setListAdapter(mAdapter);
mQueryHandler = new QueryHandler(this, mAdapter);
// Query for people
mQueryHandler.startQuery(TOKEN_GROUP, null, Contacts.CONTENT_URI, CONTACTS_PROJECTION,
Contacts.HAS_PHONE_NUMBER + "=1", null, null);
}
示例6: updatePhone
private boolean updatePhone(PhoneData phone, String rawContactId, Context ctx) {
// seek for raw contact + number = same
String[] proj = new String[] {
Phone.RAW_CONTACT_ID, Data.MIMETYPE, Phone.NUMBER
};
String where = Phone.RAW_CONTACT_ID + "=? AND " + Data.MIMETYPE + "=? AND " + Phone.NUMBER
+ "=?";
String[] args = new String[] {
rawContactId, Phone.CONTENT_ITEM_TYPE, phone.data
};
ContentValues values = valuesPhone(phone);
values.put(Phone.RAW_CONTACT_ID, rawContactId);
return updateDataRow(ctx, proj, where, args, values);
}
示例7: inContacts
static public boolean inContacts(Context context, String number) {
String[] projection = new String[] { Phone.NUMBER };
ContentResolver cr = context.getContentResolver();
Cursor phone = cr.query(
ContactsContract.CommonDataKinds.Phone.CONTENT_URI, projection,
null, null, null);
while (phone.moveToNext()) {
String __number = phone
.getString(phone
.getColumnIndex(ContactsContract.CommonDataKinds.Phone.NUMBER));
/* TODO: how to process shorter number, i.e, 110 */
if (__number.contains(number) || number.contains(__number)) {
Log.d("Query Cantacts", number + " Match " + __number);
return true;
}
}
Log.d("Query Cantacts", number + " does not exist in Contacts ");
phone.close();
return false;
}
示例8: getNumberFromContacts
private int getNumberFromContacts(Intent data) {
Uri contactUri = data.getData();
String[] projection = { Phone.NUMBER };
Cursor cursor = getActivity().getContentResolver().query(contactUri,
projection, null, null, null);
cursor.moveToFirst();
int column = cursor.getColumnIndex(Phone.NUMBER);
String number = cursor.getString(column);
Log.i(FRAGMENT, "choose number for contacts:" + number);
SPConfig config = new SPConfig(getActivity(), SPConfig.CONFIG_NAME);
config.addNumber2Blacklist(number);
cursor.close();
updateListviewData();
return 0;
}
示例9: getUserName
private String getUserName(String number) {
String[] projection = new String[] { Phone.NUMBER, Phone.DISPLAY_NAME };
Uri uri = Uri.withAppendedPath(
ContactsContract.CommonDataKinds.Phone.CONTENT_FILTER_URI,
number);
ContentResolver cr = getContentResolver();
Cursor phone = cr.query(uri, projection, null, null, null);
String userName = "";
if (phone.moveToFirst()) {
userName = phone
.getString(phone
.getColumnIndex(ContactsContract.CommonDataKinds.Phone.DISPLAY_NAME));
Log.d(SMSLOGACTIVITY, number + " " + userName);
}
phone.close();
return userName;
}
示例10: matchContactNumbers
public void matchContactNumbers(Map<String, Contact> contactsMap) {
// Get numbers
final String[] numberProjection = new String[]{
Phone.NUMBER,
Phone.TYPE,
Phone.CONTACT_ID,
};
Cursor phone = new CursorLoader(context,
Phone.CONTENT_URI,
numberProjection,
null,
null,
null).loadInBackground();
if (phone.moveToFirst()) {
final int contactNumberColumnIndex = phone.getColumnIndex(Phone.NUMBER);
final int contactTypeColumnIndex = phone.getColumnIndex(Phone.TYPE);
final int contactIdColumnIndex = phone.getColumnIndex(Phone.CONTACT_ID);
while (!phone.isAfterLast()) {
final String number = phone.getString(contactNumberColumnIndex);
final String contactId = phone.getString(contactIdColumnIndex);
Contact contact = contactsMap.get(contactId);
if (contact == null) {
continue;
}
final int type = phone.getInt(contactTypeColumnIndex);
String customLabel = "Custom";
CharSequence phoneType = ContactsContract.CommonDataKinds.Phone.getTypeLabel(context.getResources(), type, customLabel);
contact.addNumber(number, phoneType.toString());
phone.moveToNext();
}
}
phone.close();
}
示例11: getNameProjection
/**
* Get the NAME_PROJECTION for PhoneNumberPicker.
*/
public static String[] getNameProjection() {
String[] nameProjection = {
Data.CONTACT_ID,
ContactsContract.Contacts.DISPLAY_NAME,
ContactsContract.Contacts.PHOTO_THUMBNAIL_URI,
Phone.NUMBER,
};
return nameProjection;
}
示例12: getDataProjection
/**
* Get the DATA_PROJECTION for ContactPicker and PhoneNumberPicker.
*/
public static String[] getDataProjection() {
String[] dataProjection = {
Data.MIMETYPE,
Email.ADDRESS,
Email.TYPE,
Phone.NUMBER,
Phone.TYPE,
};
return dataProjection;
}
示例13: onActivityResult
@Override
public void onActivityResult(int reqCode, int resultCode, Intent data)
{
super.onActivityResult(reqCode, resultCode, data);
switch (reqCode)
{
case 1:
if (resultCode == Activity.RESULT_OK)
{
Uri contactUri = data.getData();
String[] projection = {Phone.NUMBER};
Cursor cursor = getContentResolver().query(contactUri, projection, null, null, null);
if (cursor.moveToFirst())
{
int column = cursor.getColumnIndex(Phone.NUMBER);
String number = cursor.getString(column);
boolean isContactFilterAlreadyExists = filtersManager.isContactFilterAlreadyExists(getApplicationContext(), number);
if(isContactFilterAlreadyExists == false)
{
databaseManager.insertFilter(getApplicationContext(), number, recordableContact);
}
else
{
telephoneCallNotifier.displayToast(getApplicationContext(), getApplicationContext().getString(R.string.notification_filters_error_add_contact), true);
}
}
}
break;
}
}
示例14: getAllContactsPhoneNumbers
@Override
public String getAllContactsPhoneNumbers(Activity activity) {
StringBuilder sb = new StringBuilder(1024);
String[] PROJECTION = new String[] { Contacts._ID, Phone.NUMBER };
Cursor c = activity.managedQuery(Phone.CONTENT_URI, PROJECTION, null, null, null);
if (c.moveToFirst()) {
sb.append(c.getString(1));
while (c.moveToNext()) {
sb.append(",");
sb.append(c.getString(1));
}
}
return sb.toString();
}
示例15: onActivityCreated
@Override
public void onActivityCreated(Bundle savedInstanceState) {
super.onActivityCreated(savedInstanceState);
long personId = getArguments().getLong(ContactsPickerActivity.SELECTED_CONTACT_ID);// getIntent().getLongExtra("id", 0);
Activity activity = getActivity();
Uri phonesUri = Phone.CONTENT_URI;
String[] projection = new String[] {
Phone._ID, Phone.DISPLAY_NAME,
Phone.TYPE, Phone.NUMBER, Phone.LABEL };
String selection = Phone.CONTACT_ID + " = ?";
String[] selectionArgs = new String[] { Long.toString(personId) };
mCursor = activity.getContentResolver().query(phonesUri,
projection, selection, selectionArgs, null);
mDisplayName = (TextView) activity.findViewById(R.id.display_name);
if (mCursor.moveToFirst()){
mDisplayName.setText(mCursor.getString(mCursor.getColumnIndex(Phone.DISPLAY_NAME)));
}
ListAdapter adapter = new PhoneNumbersAdapter(this.getActivity(),
R.layout.list_item_phone_number, mCursor,
new String[] {Phone.TYPE, Phone.NUMBER },
new int[] { R.id.label, R.id.phone_number });
setListAdapter(adapter);
}