简体   繁体   中英

how to get phone number from SMS android

I am doing one application, and because of security, I need to know that the application has a phone number.

I would like to know if it is possible to take the phone number which has received the SMS from the SMS (not the sending one... I would like to know which number RECIEVES the sms).

Thanks!!

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

you will need readphone permision

this is the message uri for sent message table,

content://sms/sent

read it and get address column value... you will get all the sent messages and the numbers on which the messages sent. you can do

Cursor cr= resolver.quer(Uri.parse(content://sms/sent),--------)

cr.getColumnNames() // by this method you will have all the column available in this uri. read whatever you want

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM