我对该部分有疑问。当我从联系人列表中选择电话号码时,如何删除国家代码?
例如:+91 999999999 代替 9999999999 或 +020 9696854549 代替 9696854549 谁能知道我的问题的答案。请给出这个问题的解决方案
我在这里附上了我的代码和图片。
private void contactPicked(Intent data) {
Cursor cursor = null;
try {
String phoneNo = null ;
// getData() method will have the Content Uri of the selected contact
Uri uri = data.getData();
//Query the content uri
cursor = getContentResolver().query(uri, null, null, null, null);
cursor.moveToFirst();
// column index of the phone number
int phoneIndex =cursor.getColumnIndex(ContactsContract.CommonDataKinds.Phone.NUMBER
phoneNo = cursor.getString(phoneIndex);
String phoneNumber = phoneNo.replaceAll(" ","");
mobile_et.setText(phoneNumber);
} catch (Exception e) { …Run Code Online (Sandbox Code Playgroud)