android學習—— setContentView() 的前世今生,setcontentview
SmsManager公有方法:
- ArrayList<String> divideMessage(String text)
當簡訊超過SMS訊息的最大長度時,將簡訊分割為幾塊。
參數:text——初始的訊息,不可為空
傳回值:有序的ArrayList<String>,可以重新組合為初始的訊息
- static SmsManager getDefault()
擷取SmsManager的預設執行個體。
傳回值:SmsManager的預設執行個體
- void SendDataMessage(String destinationAddress, String scAddress, short destinationPort, byte[] data, PendingIntent sentIntent, PendingIntent deliveryIntent)
發送一個基於SMS的資料到指定的應用程式連接埠。
參數:
1)、destinationAddress——訊息的目標地址
2)、scAddress——服務中心的地址or為空白使用當前預設的SMSC 3)destinationPort——訊息的目標連接埠號碼
4)、data——訊息的主體,即訊息要發送的資料
5)、sentIntent——如果不為空白,當訊息成功發送或失敗這個PendingIntent就廣播。結果代碼是Activity.RESULT_OK表示成功,或RESULT_ERROR_GENERIC_FAILURE、RESULT_ERROR_RADIO_OFF、RESULT_ERROR_NULL_PDU之一表示錯誤。對應RESULT_ERROR_GENERIC_FAILURE,sentIntent可能包括額外的“錯誤碼”包含一個無線電廣播技術特定的值,通常只在修複故障時有用。
每一個基於SMS的應用程式控制檢測sentIntent。如果sentIntent是空,調用者將檢測所有未知的應用程式,這將導致在檢測的時候發送較小數量的SMS。
6)、deliveryIntent——如果不為空白,當訊息成功傳送到接收者這個PendingIntent就廣播。
異常:如果destinationAddress或data是空時,拋出IllegalArgumentException異常。
- void sendMultipartTextMessage(String destinationAddress, String scAddress, ArrayList<String>parts, ArrayList<PendingIntent> sentIntents, ArrayList<PendingIntent> deliverIntents)
發送一個基於SMS的多部分文本,調用者應用已經通過調用divideMessage(String text)將訊息分割成正確的大小。
參數:
1)、destinationAddress——訊息的目標地址
2)、scAddress——服務中心的地址or為空白使用當前預設的SMSC
3)、parts——有序的ArrayList<String>,可以重新組合為初始的訊息
4)、sentIntents——跟SendDataMessage方法中一樣,只不過這裡的是一組PendingIntent
5)、deliverIntents——跟SendDataMessage方法中一樣,只不過這裡的是一組PendingIntent
異常:如果destinationAddress或data是空時,拋出IllegalArgumentException異常。
- void sendTextMessage(String destinationAddress, String scAddress, String text, PendingIntent sentIntent, PendingIntent deliveryIntent)
發送一個基於SMS的文本。參數的意義和異常前面的已存在的一樣,不再累述。
常量:
- public static final int RESULT_ERROR_GENERIC_FAILURE
表示普通錯誤,值為1(0x00000001)
- public static final int RESULT_ERROR_NO_SERVICE
表示服務當前不可用,值為4 (0x00000004)
- public static final int RESULT_ERROR_NULL_PDU
表示沒有提供pdu,值為3 (0x00000003)
- public static final int RESULT_ERROR_RADIO_OFF
表示無線廣播被明確地關閉,值為2 (0x00000002)
- public static final int STATUS_ON_ICC_FREE
表示自由空間,值為0 (0x00000000)
- public static final int STATUS_ON_ICC_READ
表示接收且已讀,值為1 (0x00000001)
- public static final int STATUS_ON_ICC_SENT
表示儲存且已發送,值為5 (0x00000005)
- public static final int STATUS_ON_ICC_UNREAD
表示接收但未讀,值為3 (0x00000003)
- public static final int STATUS_ON_ICC_UNSENT
表示儲存但為發送,值為7 (0x00000007)