Re: [android-developers] Re: How to find phone number in android

2011-11-03 Thread Chirag Raval
Gets the phone number the app is running on.
It needs a permission so add the line uses-permission
android:name=android.permission.READ_PHONE_STATE to the manifest.xml  

private String getMyPhoneNumber()
{
   TelephonyManager mTelephonyMgr;
   mTelephonyMgr =
(TelephonyManager)getSystemService(Context.TELEPHONY_SERVICE);
   return mTelephonyMgr.getLine1Number();
}

private String getMy10DigitPhoneNumber()
{
String s = getMyPhoneNumber();
return s.substring(2);
}

Note : Keep in mind that phone number may NOT be available, depending
on the carrier.

On Thu, Nov 3, 2011 at 5:03 PM, suresh sureshmca.sv...@gmail.com wrote:
 hi Ratheesh can u tel me which settings i should give.

 On Nov 3, 4:23 pm, Ratheesh Valamchuzhy android...@gmail.com wrote:
 make sure you give all the settings

 --
 You received this message because you are subscribed to the Google
 Groups Android Developers group.
 To post to this group, send email to android-developers@googlegroups.com
 To unsubscribe from this group, send email to
 android-developers+unsubscr...@googlegroups.com
 For more options, visit this group at
 http://groups.google.com/group/android-developers?hl=en

-- 
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en


Re: [android-developers] Re: How to find phone number in android

2011-11-03 Thread ram prasad
Hi Suresh,

I think you got empty string displayed.Actually  getting mobile number
is depends on your Network provider. If Network operator allows to take sim
number from device, it will work I think other countries are providing
this service...

I also tried lot of methods but not works for Indian network providers...

Another way is there, we can get sim serial number programmatically...

TelephonyManager manager
=(TelephonyManager)getSystemService(Context.TELEPHONY_SERVICE);
simserial= manager.getSimSerialNumber() ; //get sim serial number

by using this method we can get serial number of SIM(printed on Sim) and
match this number mobile number in database...Draw back of this method is
we should know the mobile number of particular serial before proceeding
this...

I hope this will help You to think...

On Thu, Nov 3, 2011 at 5:03 PM, suresh sureshmca.sv...@gmail.com wrote:

 hi Ratheesh can u tel me which settings i should give.

 On Nov 3, 4:23 pm, Ratheesh Valamchuzhy android...@gmail.com wrote:
  make sure you give all the settings

 --
 You received this message because you are subscribed to the Google
 Groups Android Developers group.
 To post to this group, send email to android-developers@googlegroups.com
 To unsubscribe from this group, send email to
 android-developers+unsubscr...@googlegroups.com
 For more options, visit this group at
 http://groups.google.com/group/android-developers?hl=en




-- 
BY

R.RAMPRASAD

-- 
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en