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


Java Phone.NUMBER属性代码示例

本文整理汇总了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();
        }
    }
}
 
开发者ID:AppHero2,项目名称:Raffler-Android,代码行数:21,代码来源:RegisterUserActivity.java

示例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();
}
 
开发者ID:whereuat,项目名称:whereuat-android,代码行数:26,代码来源:PhonebookUtils.java

示例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;
}
 
开发者ID:Lux1041,项目名称:Contacts,代码行数:27,代码来源:GetContactInfo.java

示例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;
}
 
开发者ID:vaslabs,项目名称:SDC,代码行数:23,代码来源:ContactsListFragment.java

示例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);
}
 
开发者ID:luoqii,项目名称:ApkLauncher,代码行数:22,代码来源:ExpandableList2.java

示例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);
    }
 
开发者ID:SafeSlingerProject,项目名称:SafeSlinger-Android,代码行数:16,代码来源:ContactAccessorApi5.java

示例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;
}
 
开发者ID:TonyNie,项目名称:intercepter,代码行数:24,代码来源:PhoneStatReceiver.java

示例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;
}
 
开发者ID:TonyNie,项目名称:intercepter,代码行数:19,代码来源:BLFragment.java

示例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;
}
 
开发者ID:TonyNie,项目名称:intercepter,代码行数:20,代码来源:SMSLogActivity.java

示例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();
}
 
开发者ID:amit-upadhyay-IT,项目名称:contacts-search-android,代码行数:37,代码来源:ContactFetcher.java

示例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;
}
 
开发者ID:mit-cml,项目名称:appinventor-extensions,代码行数:12,代码来源:HoneycombMR1Util.java

示例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;
}
 
开发者ID:mit-cml,项目名称:appinventor-extensions,代码行数:13,代码来源:HoneycombMR1Util.java

示例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;
	}
}
 
开发者ID:vassela,项目名称:AC2RD,代码行数:36,代码来源:Filters.java

示例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();
}
 
开发者ID:Kamshak,项目名称:foursquared,代码行数:14,代码来源:AddressBookUtils5.java

示例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);
}
 
开发者ID:vaslabs,项目名称:SDC,代码行数:28,代码来源:ContactDetailsFragment.java


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