phone-number

How to format a string as a telephone number in C#

扶醉桌前 提交于 2019-11-26 06:04:49
问题 I have a string \"1112224444\' it is a telephone number. I want to format as 111-222-4444 before I store it in a file. It is on a datarecord and I would prefer to be able to do this without assigning a new variable. I was thinking: String.Format(\"{0:###-###-####}\", i[\"MyPhone\"].ToString() ); but that does not seem to do the trick. ** UPDATE ** Ok. I went with this solution Convert.ToInt64(i[\"Customer Phone\"]).ToString(\"###-###-#### ####\") Now its gets messed up when the extension is

Phone validation regex

梦想与她 提交于 2019-11-26 05:26:26
问题 I\'m using this pattern to check the validation of a phone number ^[0-9\\-\\+]{9,15}$ It\'s works for 0771234567 and +0771234567 , but I want it to works for 077-1234567 and +077-1234567 and +077-1-23-45-67 and +077-123-45-6-7 What should I change in the pattern? 回答1: 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

Android: Retrieve contact name from phone number

久未见 提交于 2019-11-26 05:26:24
问题 I would like to retrieve the name of a contact associated with an incoming telephone number. As I process the incoming number in the broascastreceiver having a String with the name of the incoming caller would help my project greatly. I would think this involves a query using the sql WHERE clause as a filter, but do I need to sort the contacts? An example or hint would be of great assistance. 回答1: For that you need to use the optimized PhoneLookup provider as described. Add the permission to

How do I get the dialer to open with phone number displayed?

旧巷老猫 提交于 2019-11-26 03:49:09
问题 I don\'t need to call the phone number, I just need the dialer to open with the phone number already displayed. What Intent should I use to achieve this? 回答1: Two ways to achieve it. 1) Need to start the dialer via code, without user interaction. You need Action_Dial , use below code it will open Dialer with number specified Intent intent = new Intent(Intent.ACTION_DIAL); intent.setData(Uri.parse("tel:0123456789")); startActivity(intent); The 'tel:' prefix is required , otherwhise the

Phone number formatting on iOS

天大地大妈咪最大 提交于 2019-11-26 03:47:57
问题 I have a text field where the user enters data. It\'s a phone number field. If the user enters 1234567890 , I want it displayed as (123)-(456)-7890 as the user types. How is this possible? 回答1: 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;

Calling a phone number in swift

╄→гoц情女王★ 提交于 2019-11-26 03:37:53
问题 I\'m trying to call a number not using specific numbers but a number that is being called in a variable or at least tell it to pull up the number in your phone. This number that is being called in a variable is a number that I retrieved by using a parser or grabbing from a website sql. I made a button trying to call the phone number stored in the variable with a function but to no avail. Anything will help thanks! func callSellerPressed (sender: UIButton!){ //(This is calls a specific number

Read all contacts' phone numbers in android

不打扰是莪最后的温柔 提交于 2019-11-26 03:37:39
I'm using this code to retrieve all contact names and phone numbers: String[] projection = new String[] { People.NAME, People.NUMBER }; Cursor c = ctx.getContentResolver().query(People.CONTENT_URI, projection, null, null, People.NAME + " ASC"); c.moveToFirst(); int nameCol = c.getColumnIndex(People.NAME); int numCol = c.getColumnIndex(People.NUMBER); int nContacts = c.getCount(); do { // Do something } while(c.moveToNext()); However, this will only return the primary number for each contact, but I want to get the secondary numbers as well. How can i do this? You can read all of the telephone

A comprehensive regex for phone number validation

那年仲夏 提交于 2019-11-26 03:13:31
问题 I\'m trying to put together a comprehensive regex to validate phone numbers. Ideally it would handle international formats, but it must handle US formats, including the following: 1-234-567-8901 1-234-567-8901 x1234 1-234-567-8901 ext1234 1 (234) 567-8901 1.234.567.8901 1/234/567/8901 12345678901 I\'ll answer with my current attempt, but I\'m hoping somebody has something better and/or more elegant. 回答1: Better option... just strip all non-digit characters on input (except 'x' and leading '+'

What's the right way to represent phone numbers?

让人想犯罪 __ 提交于 2019-11-26 01:53:45
问题 I\'m having trouble representing a mobile number in one of my applications. I was wondering if there is an Integer class that will allow you to store such a number starting with 0417254482. Perhaps using a string be a more appropriate? At present when I\'m trying to use represent a phone number with ints, doubles longs I seem to store random numbers and not the numbers I meant to store. 回答1: Use String . Aside from anything else, you won't be able to store leading zeroes if you use integers.

Programmatically obtain the phone number of the Android phone

会有一股神秘感。 提交于 2019-11-26 01:18:08
问题 How can I programmatically get the phone number of the device that is running my android app? 回答1: Code: TelephonyManager tMgr = (TelephonyManager)mAppContext.getSystemService(Context.TELEPHONY_SERVICE); String mPhoneNumber = tMgr.getLine1Number(); Required Permission: <uses-permission android:name="android.permission.READ_PHONE_STATE"/> Caveats: According to the highly upvoted comments, there are a few caveats to be aware of. This can return null or "" or even "???????" , and it can return a