TelephonyManager tm = (TelephonyManager) this.getSystemService(this.TELEPHONY_SERVICE);
phoneNumber1 = tm.getLine1Number();
Log.w("TelephonyManager", "phoneNumber1============" + phoneNumber1);
IntentFilter mFilter01;
mFilter01 = new IntentFilter(SENT_SMS_ACTION);
registerReceiver(sendMessage, mFilter01);
mFilter01 = new IntentFilter(DELIVERED_SMS_ACTION);
registerReceiver(receiver, mFilter01);
String phoneNumber1;
String SENT_SMS_ACTION = "SENT_SMS_ACTION";
String DELIVERED_SMS_ACTION = "DELIVERED_SMS_ACTION";
private BroadcastReceiver sendMessage = new BroadcastReceiver() {
@Override
public void onReceive(Context context, Intent intent) {
Log.w("============", "send。。" + intent.getAction() + "====" + getResultCode() + "====" + getResultData());
switch (getResultCode()) {
case Activity.RESULT_OK:
Log.w("============", "DXFSCG============" );
break;
default:
Log.w("============", "DXFASB=========" );
break;
}
}
};
private BroadcastReceiver receiver = new BroadcastReceiver() {
@Override
public void onReceive(Context context, Intent intent) {
Log.w("============", "DXFASB对方接收成功==========");
}
};
private void sendSMS() {
SmsManager sms = SmsManager.getDefault();
Intent sentIntent = new Intent(SENT_SMS_ACTION);
PendingIntent sentPI = PendingIntent.getBroadcast(this, 0, sentIntent, 0);
Intent deliverIntent = new Intent(DELIVERED_SMS_ACTION);
PendingIntent deliverPI = PendingIntent.getBroadcast(this, 0, deliverIntent, 0);
sms.sendTextMessage("", null, "xiao fa ", sentPI, deliverPI);
Log.w("============", "============");
}