Skip to content Skip to sidebar Skip to footer

How To Get Owner/sim Number And Network Mode

I want to get the SIM number which currently in the phone i.e. owner number. and network mode whether it is GSM or CDMA. I search on net and try to do this by getLine1Number(); bu

Solution 1:

to get the number of ur SIM CARD , and the network u can do this :

TelephonyManager tm = (TelephonyManager) this.getSystemService(Context.TELEPHONY_SERVICE);

    ConnectivityManager cm = (ConnectivityManager) this.getSystemService(Context.CONNECTIVITY_SERVICE);
        if(cm.getActiveNetworkInfo().getTypeName().equals("MOBILE"))
            network = "cellnetwork/3G";
        elseif(cm.getActiveNetworkInfo().getTypeName().equals("WIFI"))
            network = "wifi";
        else 
            network ="na";

    uphone = tm.getLine1Number();

hope it hepls :)

i've tried it , and it works for me

Solution 2:

For the phone number you can do,

// Get the phone number from the telephony manager, and display itTelephonyManagerinfo= (TelephonyManager)getApplicationContext().getSystemService(Context.TELEPHONY_SERVICE);
StringphoneNumber= info.getLine1Number();

For the network mode, see TelephonyManager

Solution 3:

Solution 4:

To get the phone number, try the TelephonyManager.

If that does not work you can get this info through AccountManager. One of the accounts will be the number.

See source details implementation on this post: TelephonyManager.getLine1Number() failing?

Post a Comment for "How To Get Owner/sim Number And Network Mode"