** android.provider.Telephony.SMS_SENT无法正常工作**
@Override
public void onReceive(Context context, Intent intent) {
initObjects(context);
if (intent.getAction().equals(android.provider.Telephony.SMS_RECEIVED)) {
// message detail fetching
getAllSms(context);
// initializeList();
}else
if(intent.getAction().equals(android.provider.Telephony.SMS_SENT) ){
getAllSms(context);
} else{
Toast.makeText(context, "this intent filter action is not working", Toast.LENGTH_SHORT).show();
}
}
答案 0 :(得分:0)
将此代码添加到您的OnResume回叫中
sentStatusReceiver =新的BroadcastReceiver(){
@Override
public void onReceive(Context arg0, Intent arg1) {
String s = "Unknown Error";
switch (getResultCode()) {
case Activity.RESULT_OK:
s = "Message Sent Successfully !!";
break;
case SmsManager.RESULT_ERROR_GENERIC_FAILURE:
s = "Generic Failure Error";
break;
case SmsManager.RESULT_ERROR_NO_SERVICE:
s = "Error : No Service Available";
break;
case SmsManager.RESULT_ERROR_NULL_PDU:
s = "Error : Null PDU";
break;
case SmsManager.RESULT_ERROR_RADIO_OFF:
s = "Error : Radio is off";
break;
default:
break;
}
sendStatusTextView.setText(s);
}
};
这里是短信详细信息的代码
Cursor cursor = getContentResolver().query(Uri.parse("content://sms/inbox"),
null, null, null, null);
if (cursor.moveToFirst()) { // must check the result to prevent exception
do {
String msgData = "";
for(int idx=0;idx<cursor.getColumnCount();idx++)
{
msgData += " " + cursor.getColumnName(idx) + ":" + cursor.getString(idx);
}
// use msgData
} while (cursor.moveToNext());
} else {
// empty box, no SMS
}