android - Retrieving phone number from SIM card error -
this code
telephonymanager mtelephonymgr = (telephonymanager)context.getsystemservice(context.telephony_service); string sdeviceid = mtelephonymgr.getdeviceid(); string ssimserial = mtelephonymgr.getsimserialnumber(); string ssimlinenumber = mtelephonymgr.getline1number();
with of want read user phone number his/her sim card add read_phone_state
permission in manifest file. eclipse showing no error in code still nothing in end. there wrong code?
see this thread more information on issue. specifically, below comment on accepted answer:
actually, not perfect. last time tried method, reported phone number phone had, before old mobile number ported on it. still does, settings app still shows defunct number. also, there reports sims cause method return null. being said, i'm not aware of better answer. – commonsware
it seems getting user's phone number not simple asking os hand over, reasons beyond control of developer. alternative populate whichever field need number os gives, let user edit phone number in case os wrong.
Comments
Post a Comment