小编New*_*New的帖子

如何删除国家代码,当从联系人中选择电话号码时

在此处输入图片说明

我对该部分有疑问。当我从联系人列表中选择电话号码时,如何删除国家代码?

例如:+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)

java android telephonymanager

3
推荐指数
2
解决办法
2万
查看次数

标签 统计

android ×1

java ×1

telephonymanager ×1