Android Apps

Get mobilenumber from Sim card – Android app development

July 25, 2012 by Sarath DR in Android Apps, Featured with 1 Comment

simLARGE060112 e1343258297348 Get mobilenumber  from Sim card   Android app development

Sometimes you have to retrieve the MSISDN ( Mobile Subscriber Integrated Services Digital Network-Number ) from the SIM card but it is not reliable since some operator does not provide the mobile number info inside the sim card. It is not necessary to have the mobile number in sim card instead mobile operators use an unique identifier for each SIM card called IMSI number. HLR ( Home Location Register ) has this details and it is a primary key in HLR for the actual mobile number look up.

The below code returns the MSISDN if the sim card contains that info.

import android.telephony.TelephonyManager;
 
      public  String getMsisdn()
       {
       	 TelephonyManager mTelephonyMgr = (TelephonyManager) this.getSystemService(Context.TELEPHONY_SERVICE);
       	 String msisdn = mTelephonyMgr.getLine1Number();
       	 if( msisdn == null )
       	 {
       		 return "";
       	 }
       	 return msisdn; 
       }

Tagged ,

Share this to

One Comment

  1. Raman GhaiApr 22, 2013 at 7:59 amReply

    Most of the cases , it gives ” ” as the mobile number . Is there any other way to find the mobile number of android device ?

Leave a reply

Your email address will not be published. Required fields are marked *

*

About
View Sarath D R's profile on LinkedIn

I am a technology consultant and an entrepreneur focused on the following technologies Java,Spring, Android, Angular, Asterisk, Symfony, Cake , Code-Igniter, Jquery , XAMPP, XHTML, AJAX, MySql, Seo, Web Design, Wordpress, iPhone development.

Today’s Tips
  • Generate Codova.jar file from Phonegap project using ant
  • Google map javascript client  to find the geographic co-ordinates  from  Address or post code
  • Update Android main UI from Webview – Phonegap Plugin
  • Jplayer is not working  with HTC One Android 4.3 version browser
  • Regular expression to validate mobile phone numbers starting with + ( plus ) – php
  • Simple pagination script for PHP
  • Useful adb ( Android Debug Bridge ) commands
  • Change the javascript files url to absolute url – Symfony 1.4
  • Set Http authentication header from Client – PHP / CURL

This site uses cookies from Google to deliver its services, to personalise ads and to analyse traffic. Information about your use of this site is shared with Google. By using this site, you agree to its use of cookies. more information

The cookie settings on this website are set to "allow cookies" to give you the best browsing experience possible. If you continue to use this website without changing your cookie settings or you click "Accept" below then you are consenting to this.This site also uses cookies from Google to deliver its services, to personalise ads and to analyse traffic. Information about your use of this site is shared with Google. By using this site, you agree to its use of cookies.

Close