我有这个代码,我读取有关短信的所有信息:
Uri mSmssentQueryUri = Uri.parse("content://sms/sent");
Cursor cursorS = getContentResolver().query(mSmssentQueryUri,null, null, null, null);
if (cursorS.getCount() > 0) {
while (cursorS.moveToNext()){
date = cursorS.getString(4);
address = cursorS.getString(2);
JSONObject jsonSms= new JSONObject();
jsonSms.put("type", "sms");
jsonSms.put("date", date);
jsonSms.put("receiver", address);
jsonSms.put("direction", "OUTGOING");
jsonObj.put("SMS"+date, jsonSms);
}
}
我对使用CallLog的调用做同样的事情。呼叫,但我可以找到更多的信息,如countryIso,它给我的国家代码的用户收到或拨打电话。当我发送短信时,是否有一种方法可以获得相同的信息,这样我就可以读到短信是从国外发送的?
在下面的函数中传递地址字段值作为电话
PhoneNumberUtil phoneUtil = PhoneNumberUtil.getInstance();
try {
// phone must begin with '+'
PhoneNumber numberProto = phoneUtil.parse(phone, "");
int countryCode = numberProto.getCountryCode();
} catch (NumberParseException e) {
System.err.println("NumberParseException was thrown: " + e.toString());
}