我已配置了 <uses-permission android:name="android.permission.CALL_PHONE" />
<uses-permission android:name="android.permission.SEND_SMS"/>
<uses-permission android:name="android.permission.RECEIVE_SMS"/> 所需的权限。
定义了方法:private void sendMsg(String number, String message){
String SENT = "sms_sent";
String DELIVERED = "sms_delivered";
PendingIntent sentPI = PendingIntent.getActivity(this, 0, new Intent(SENT), 0);
PendingIntent deliveredPI = PendingIntent.getActivity(this, 0, new Intent(DELIVERED), 0);
registerReceiver(new BroadcastReceiver(){
@Override
public void onReceive(Context context, Intent intent) {
switch(getResultCode())
{
case Activity.RESULT_OK:
{
Log.i("====>", "Activity.RESULT_OK");
}
break;
case SmsManager.RESULT_ERROR_GENERIC_FAILURE:
Log.i("====>", "RESULT_ERROR_GENERIC_FAILURE");
break;
case SmsManager.RESULT_ERROR_NO_SERVICE:
Log.i("====>", "RESULT_ERROR_NO_SERVICE");
break;
case SmsManager.RESULT_ERROR_NULL_PDU:
Log.i("====>", "RESULT_ERROR_NULL_PDU");
break;
case SmsManager.RESULT_ERROR_RADIO_OFF:
Log.i("====>", "RESULT_ERROR_RADIO_OFF");
break;
}
}
}, new IntentFilter(SENT));
registerReceiver(new BroadcastReceiver(){
@Override
public void onReceive(Context context, Intent intent){
switch(getResultCode())
{
case Activity.RESULT_OK:
Log.i("====>", "RESULT_OK");
break;
case Activity.RESULT_CANCELED:
Log.i("=====>", "RESULT_CANCELED");
break;
}
1 个解决方案
#1
您的发送的方法呢?
#1
您的发送的方法呢?