0

is there any way to find the mobile operator for the number entered by the user in edit text. just like paytm. when user enter the phone number. it will automatically fetch the operator name.

i have following code to find the user device operator name. but i need to find the operator name when user enter the mobile number in edit text.

    TelephonyManager telephonyManager = (TelephonyManager)getSystemService(Context.TELEPHONY_SERVICE);

String operatername = telephonyManager.getNetworkOperatorName();

benarjee bojja
  • 348
  • 1
  • 3
  • 15

3 Answers3

3

If you want to get the operator name of entered mobile number. You have to use third party software's like InfoBip

With below code, you will get only your sim operating name and other details

    TelephonyManager telephonyManager = (TelephonyManager)getSystemService(Context.TELEPHONY_SERVICE);
   String carrierName = tManager.getNetworkOperatorName();
Ameer
  • 2,709
  • 1
  • 28
  • 44
  • 1
    You have to use any third part application. Or you can manually check with first four digits of mobile number. Still lots of people will port their number – Ameer Jul 12 '17 at 06:11
0

You can try this

 // Get System TELEPHONY service reference
  TelephonyManager tManager = (TelephonyManager) getBaseContext()
        .getSystemService(Context.TELEPHONY_SERVICE);

  // Get carrier name (Network Operator Name)
  String carrierName = tManager.getNetworkOperatorName();

For more information, refer to this link

Aarif Aslam
  • 1,077
  • 10
  • 15
0

For any android device

//above 22
     if (Build.VERSION.SDK_INT > 22) {
            //for dual sim mobile
            SubscriptionManager localSubscriptionManager = SubscriptionManager.from(this);

            if (localSubscriptionManager.getActiveSubscriptionInfoCount() > 1) {
             //if there are two sims in dual sim mobile
                List localList = localSubscriptionManager.getActiveSubscriptionInfoList();
                SubscriptionInfo simInfo = (SubscriptionInfo) localList.get(0);
                SubscriptionInfo simInfo1 = (SubscriptionInfo) localList.get(1);

                final String sim1 = simInfo.getDisplayName().toString();
                final String sim2 = simInfo1.getDisplayName().toString();

            }else{
             //if there is 1 sim in dual sim mobile
                TelephonyManager tManager = (TelephonyManager) getBaseContext()
                        .getSystemService(Context.TELEPHONY_SERVICE);

                String sim1 = tManager.getNetworkOperatorName();

            }

        }else{
            //below android version 22
                    TelephonyManager tManager = (TelephonyManager) getBaseContext()
                            .getSystemService(Context.TELEPHONY_SERVICE);

                    String sim1 = tManager.getNetworkOperatorName();
        }
Lakpriya Senevirathna
  • 2,488
  • 2
  • 17
  • 35