當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。