我试图从我设备的 SMS 收件箱/发件箱中检索所有信息。但是我的手机号码,即发件人的手机号码似乎没有被存储。我正在尝试获取此号码,以便我可以从 OUTBOX 捕获手机号码并允许用户使用它在我的应用程序上注册,考虑到它接近用户在设备上使用的准确手机号码。这样他们就不必在我的应用程序中输入手机进行注册。
请让我知道是否有任何方法可以从 SMS INBOX/SENT 中找到手机号码
代码在这里:
public void readSMS (Activity MainActivity)
{
Uri inSMSUri = Uri.parse ("content://sms/inbox");
System.out.println ( "the URI :: " + inSMSUri);
Cursor c = MainActivity.getContentResolver().query(inSMSUri, null, null, null, "date desc");
if (c!= null)
{
StringBuilder sb = new StringBuilder ();
while (c.moveToNext ()) {
System.out.println ("content:" + c.getString (c.getColumnIndex ("body")));
for(int i=0; i<c.getColumnCount();i++)
{
System.out.println("SMS:INBOX: c getColumnName(i):: "+c.getColumnName(i) +
" c.getString(i):: "+c.getString(i));
}
}
c.close ();
Uri outSMSUri = Uri.parse ("content://sms/sent");
c = MainActivity.getContentResolver().query(outSMSUri, null, null, null, "date desc");
if (c!= null)
{
while (c.moveToNext ()) {
System.out.println ("content:" + c.getString (c.getColumnIndex ("body")));
for(int i=0; i<c.getColumnCount();i++)
{
System.out.println("SMS:SENT: c getColumnName(i):: "+c.getColumnName(i) +
" c.getString(i):: "+c.getString(i));
}
}
}
}
}
但未找到 SENDER 手机号码栏:
SMS INBOX 正在生成此输出:
content:Hello! You are roaming on Vodafone Maharashtra
SMS:INBOX: c getColumnName(i):: _id c.getString(i):: 9
SMS:INBOX: c getColumnName(i):: thread_id c.getString(i):: 3
SMS:INBOX: c getColumnName(i):: address c.getString(i):: VM-VDFONE
SMS:INBOX: c getColumnName(i):: m_size c.getString(i):: 297
SMS:INBOX: c getColumnName(i):: person c.getString(i):: 0
SMS:INBOX: c getColumnName(i):: date c.getString(i):: 1381599923412
SMS:INBOX: c getColumnName(i):: date_sent c.getString(i):: 1381599913000
SMS:INBOX: c getColumnName(i):: protocol c.getString(i):: 0
SMS:INBOX: c getColumnName(i):: read c.getString(i):: 1
SMS:INBOX: c getColumnName(i):: status c.getString(i):: -1
SMS:INBOX: c getColumnName(i):: type c.getString(i):: 1
SMS:INBOX: c getColumnName(i):: reply_path_present c.getString(i):: 0
SMS:INBOX: c getColumnName(i):: subject c.getString(i):: null
SMS:INBOX: c getColumnName(i):: body c.getString(i):: Hello! You are roaming on Vodafone Maharashtra
SMS:INBOX: c getColumnName(i):: service_center c.getString(i):: +919820005556
SMS:INBOX: c getColumnName(i):: locked c.getString(i):: 0
SMS:INBOX: c getColumnName(i):: sim_id c.getString(i):: 1
SMS:INBOX: c getColumnName(i):: error_code c.getString(i):: 0
SMS:INBOX: c getColumnName(i):: seen c.getString(i):: 1
SMS:INBOX: c getColumnName(i):: ipmsg_id c.getString(i):: 0
But SENDER Mobile number column NOT found:
SMS:SENT: c getColumnName(i):: _id c.getString(i):: 1783
SMS:SENT: c getColumnName(i):: thread_id c.getString(i):: 26
SMS:SENT: c getColumnName(i):: address c.getString(i):: 1909
SMS:SENT: c getColumnName(i):: m_size c.getString(i):: null
SMS:SENT: c getColumnName(i):: person c.getString(i):: 0
SMS:SENT: c getColumnName(i):: date c.getString(i):: 1394009796560
SMS:SENT: c getColumnName(i):: error_code c.getString(i):: 0
SMS:SENT: c getColumnName(i):: seen c.getString(i):: 1
SMS:SENT: c getColumnName(i):: ipmsg_id c.getString(i):: 0
SMS:SENT: c getColumnName(i):: m_size c.getString(i):: 21
SMS:SENT: c getColumnName(i):: person c.getString(i):: 0
SMS:SENT: c getColumnName(i):: date c.getString(i):: 1392004530098
SMS:SENT: c getColumnName(i):: date_sent c.getString(i):: 0
SMS:SENT: c getColumnName(i):: protocol c.getString(i):: null
SMS:SENT: c getColumnName(i):: read c.getString(i):: 1
SMS:SENT: c getColumnName(i):: status c.getString(i):: -1
SMS:SENT: c getColumnName(i):: type c.getString(i):: 2
SMS:SENT: c getColumnName(i):: reply_path_present c.getString(i):: null
SMS:SENT: c getColumnName(i):: subject c.getString(i):: null
SMS:SENT: c getColumnName(i):: body c.getString(i):: Take care
SMS:SENT: c getColumnName(i):: service_center c.getString(i):: null
SMS:SENT: c getColumnName(i):: locked c.getString(i):: 0
SMS:SENT: c getColumnName(i):: sim_id c.getString(i):: 1
SMS:SENT: c getColumnName(i):: error_code c.getString(i):: 0
SMS:SENT: c getColumnName(i):: ipmsg_id c.getString(i):: 0