How to get the mobile number of current sim card in real device?

前端 未结 6 1597
春和景丽
春和景丽 2020-11-28 03:39

I have to make an application which shows the contact no of the SIM card that is being used in the cell. For that I need to use TelephonyManager class. Can I ge

6条回答
  •  广开言路
    2020-11-28 04:34

    Hi Actually this is my same question but I didn't get anything.Now I got mobile number and his email-Id from particular Android real device(Android Mobile).Now a days 90% people using what's App application on Android Mobile.And now I am getting Mobile no and email-ID Through this What's app API.Its very simple to use see this below code.

                AccountManager am = AccountManager.get(this);
                Account[] accounts = am.getAccounts();
          for (Account ac : accounts) 
           {
            acname = ac.name;
    
            if (acname.startsWith("91")) {
                mobile_no = acname;
            }else if(acname.endsWith("@gmail.com")||acname.endsWith("@yahoo.com")||acname.endsWith("@hotmail.com")){
                email = acname;
            }
    
            // Take your time to look at all available accounts
            Log.i("Accounts : ", "Accounts : " + acname);
        }
    

    and import this API

        import android.accounts.Account;
        import android.accounts.AccountManager;
    

提交回复
热议问题