我沒有收到使用4G網絡的BroadcastReceiver的意圖。我正在使用以下代碼來接收短信發送結果代碼。我在2G網絡中獲得了正確的結果,但是沒有獲得4G的結果。
如果有什麼意見請回復。
謝謝。使用4G網絡發送短信後,Braodcast接收器未收到Intent
registerReceiver(sendBroadcastReceiver, new IntentFilter("SENT"));
sendBroadcastReceiver = new BroadcastReceiver()
{
int result = getResultCode();
@Override
public void onReceive(Context context, Intent intent)
{
switch (result)
{
case Activity.RESULT_OK:
System.out.println("Received response");
break;
case SmsManager.RESULT_ERROR_GENERIC_FAILURE:
addFailedResultsInList("RESULT_ERROR_GENERIC_FAILURE");
break;
case SmsManager.RESULT_ERROR_NO_SERVICE:
addFailedResultsInList("RESULT_ERROR_NO_SERVICE");
break;
case SmsManager.RESULT_ERROR_NULL_PDU:
addFailedResultsInList("RESULT_ERROR_NULL_PDU");
break;
case SmsManager.RESULT_ERROR_RADIO_OFF:
addFailedResultsInList("RESULT_ERROR_RADIO_OFF");
break;
}
}
};
<uses-permission android:name="android.permission.VIBRATE" />
<uses-permission android:name="android.permission.WRITE_SMS" />
<uses-permission android:name="android.permission.READ_SMS" />
<uses-permission android:name="android.permission.RECEIVE_SMS" />
<uses-permission android:name="android.permission.SEND_SMS" />
<uses-permission android:name="android.permission.READ_CONTACTS" />
<uses-permission android:name="android.permission.READ_PHONE_STATE" />
顯示完整的代碼註冊事件
,並要求允許包括清單! –
您初始化結果的位置? –
它應該是result = getResultCode();之前swtich –