How to get the telephone number associated with the SIM in a GSM phone? [duplicate]
Asked Answered
R

1

0

Possible Duplicate:
How to fetch own mobile number in android

How to get the telephone number associated with the SIM in a GSM phone?

Renvoi answered 2/3, 2011 at 5:37 Comment(0)
E
2

try following code

TelephonyManager tMgr=(TelephonyManager)mAppContext.getSystemService(Context.TELEPHONY_SERVICE);
mPhoneNumber = tMgr.getLine1Number();

and with following permission in your xml

READ_PHONE_STATE
Eggplant answered 2/3, 2011 at 5:55 Comment(4)
can i get the details in case of dual SIMs are available in my device?Demonology
@prasad.gai- Did u got your answer...coz iam facing same problem n kinda stuck there..!!Satchel
i am getting null while fetching the sim card numberBeetroot
@AdityaNikhade too late for answer, but I answer for future viewers :) You receive nullbecause it is not mandatory to store the phone number on the SIM. i.e. some operators store it in the SIM and some others not.Cutlor

© 2022 - 2024 — McMap. All rights reserved.