1
我試圖設置一個接收短信和發送狀態的類。 這是我的清單看起來如何完成這個任務:在一個BroadcastReceiver中接收和發送短信(Android)
<receiver android:name=".SmsListener" android:permission="android.permission.BROADCAST_SMS" android:exported="true">
<intent-filter android:priority="5822">
<action android:name="android.provider.Telephony.SMS_RECEIVED" />
<action android:name="android.provider.Telephony.SMS_SENT" />
</intent-filter>
</receiver>
我得到接收的消息,但沒有得到發送的消息,是有毛病我艙單申報?
PendingIntent _pendingIntent;
Intent _intent = new Intent();
_intent.setClass(ParkingOptionsActivity.this, SmsListener.class); // SmsListener extends BroadcastReceiver
_intent.putExtra("test","test");
_pendingIntent = PendingIntent.getActivity(ParkingOptionsActivity.this, 0, _intent, 0);
SmsManager sms = SmsManager.getDefault();
sms.sendTextMessage(phoneNumber, null, "test message", _pendingIntent, null);