Android: Retrieve contact name from phone number

Although this has already been answered, but here is the complete function to get the contact name from number. Hope it will help others: public static String getContactName(Context context, String phoneNumber) { ContentResolver cr = context.getContentResolver(); Uri uri = Uri.withAppendedPath(PhoneLookup.CONTENT_FILTER_URI, Uri.encode(phoneNumber)); Cursor cursor = cr.query(uri, new String[]{PhoneLookup.DISPLAY_NAME}, null, null, null); if (cursor == null) { … Read more

International phone number max and min? [duplicate]

, where the format of telephone numbers is standardized by ITU-T in the recommendation E.164, which specifies that the entire number should be 15 digits or shorter, Source: http://en.wikipedia.org/wiki/Telephone_number Also, check this other question on SO: What’s the longest possible worldwide phone number I should consider in SQL varchar(length) for phone

Phone number formatting on iOS

This will help you Format (xxx) xxx-xxxx – (BOOL)textField:(UITextField *)textField shouldChangeCharactersInRange:(NSRange)range replacementString:(NSString *)string { int length = (int)[self getLength:textField.text]; //NSLog(@”Length = %d “,length); if(length == 10) { if(range.length == 0) return NO; } if(length == 3) { NSString *num = [self formatNumber:textField.text]; textField.text = [NSString stringWithFormat:@”(%@) “,num]; if(range.length > 0) textField.text = [NSString stringWithFormat:@”%@”,[num substringToIndex:3]]; … Read more

Phone validation regex

Please refer to this SO Post example of a regular expression in jquery for phone numbers /\(?([0-9]{3})\)?([ .-]?)([0-9]{3})\2([0-9]{4})/ (123) 456 7899 (123).456.7899 (123)-456-7899 123-456-7899 123 456 7899 1234567899 are supported

Read all contacts’ phone numbers in android

Following code shows an easy way to read all phone numbers and names: Cursor phones = getContentResolver().query(ContactsContract.CommonDataKinds.Phone.CONTENT_URI, null,null,null, null); while (phones.moveToNext()) { String name=phones.getString(phones.getColumnIndex(ContactsContract.CommonDataKinds.Phone.DISPLAY_NAME)); String phoneNumber = phones.getString(phones.getColumnIndex(ContactsContract.CommonDataKinds.Phone.NUMBER)); } phones.close(); NOTE: getContentResolver is a method from the Activity context.

Phone number validation Android

Use isGlobalPhoneNumber() method of PhoneNumberUtils to detect whether a number is valid phone number or not. Example System.out.println(“….g1…”+PhoneNumberUtils.isGlobalPhoneNumber(“+912012185234”)); System.out.println(“….g2…”+PhoneNumberUtils.isGlobalPhoneNumber(“120121852f4”)); The result of first print statement is true while the result of second is false because the second phone number contains f.

Which is best data type for phone number in MySQL and what should Java type mapping for it be?

Strings & VARCHAR. Do not try storing phone numbers as actual numbers. it will ruin the formatting, remove preceding 0s and other undesirable things. You may, if you choose to, restrict user inputs to just numeric values but even in that case, keep your backing persisted data as characters/strings and not numbers. Be aware of … Read more

Calling a phone number in swift

Just try: if let url = NSURL(string: “tel://\(busPhone)”) where UIApplication.sharedApplication().canOpenURL(url) { UIApplication.sharedApplication().openURL(url) } assuming that the phone number is in busPhone. NSURL‘s init(string:) returns an Optional, so by using if let we make sure that url is a NSURL (and not a NSURL? as returned by the init). For Swift 3: if let url = … Read more

Formatting Phone Numbers in PHP

This is a US phone formatter that works on more versions of numbers than any of the current answers. $numbers = explode(“\n”, ‘(111) 222-3333 ((111) 222-3333 1112223333 111 222-3333 111-222-3333 (111)2223333 +11234567890 1-8002353551 123-456-7890 -Hello! +1 – 1234567890 ‘); foreach($numbers as $number) { print preg_replace(‘~.*(\d{3})[^\d]{0,7}(\d{3})[^\d]{0,7}(\d{4}).*~’, ‘($1) $2-$3’, $number). “\n”; } And here is a breakdown … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)