我想阅读被阻止的SMS,MMS。 或者我想获取SMS,MMS事件(接收器,linster ...)到阻止的号码。 但是我的代码无法满足我的要求。
我使用了接收器(android.provider.Telephony.SMS_RECEIVED,android.provider.Telephony.SMS_DELIVER)
也阅读
Cursor cursor = mContext.getContentResolver().query(Telephony.Sms.CONTENT_URI, null, null, null, null)
但没有工作。
@Override
public void onReceive(Context context, Intent intent) {
Log.d(TAG, "BroadcastReceiver Received");
if ("android.provider.Telephony.SMS_RECEIVED".equals(intent.getAction())) {
Log.d(TAG, "SMS_RECEIVED");
} else if ("android.provider.Telephony.SMS_DELIVER".equals(intent.getAction())) {
Log.d(TAG, "SMS_DELIVER");
}
}
private void readSms() {
Cursor cursor = mContext.getContentResolver().query(Telephony.Sms.CONTENT_URI, null, null, null, null);
String number = "";
String sub = "";
String message = "";
while (cursor != null && cursor.moveToNext()) {
number = cursor.getString(cursor.getColumnIndex(Telephony.Sms.ADDRESS));
sub = cursor.getString(cursor.getColumnIndex(Telephony.Sms.SUBJECT));
message = cursor.getString(cursor.getColumnIndex(Telephony.Sms.BODY));
Log.d("###", "number : " + number
+ " // subject : " + sub
+ " // message : " + message
+ " // date : " + cursor.getString(cursor.getColumnIndex(Telephony.Sms.DATE))
+ " // _id : " + cursor.getString(cursor.getColumnIndex(Telephony.Sms.THREAD_ID))
+ " // type : " + cursor.getString(cursor.getColumnIndex(Telephony.Sms.TYPE))
+ " // seen : " + cursor.getString(cursor.getColumnIndex(Telephony.Sms.SEEN))
+ " // person : " + cursor.getString(cursor.getColumnIndex(Telephony.Sms.PERSON))
);
}
}
如何读取被阻止号码的短信