Android Mms專題之:PDU介紹

來源:互聯網
上載者:User

Android當中的Mms對MMS(Multimedia Messaging Service)的操作關乎MMS協議部分都是通過Frameworks中提供的API來完成的:com.google.android.mms這個包在SDK中是不開放的,只能供內部程式使用,它封裝了所有MMS所需要的API。
這個包就是Android中對MMS協議的實現,包括一些資料結構:GenericPdu,MultimediaMessagePdu,SendReq,SendConf,NotificationInd,RetrieveConf,PduHeaders,PduBody,PduPart等。也包括操作這些資料的類:PduPersister,PduParser和PduComposer。PduPersister主要供給Android內部的應用程式使用;而PduParser和PduComposer會涉及到PDU相關的協議,會與MMSC或其他平台有相互影響(比如所打包的位元組流是否符合標準,能否被其他平台成功解析和識別等)
這個包的功能就是在發送時把多媒體資料打包成標準MMSC能識別的PDU格式資料,在接收時把PDU資料包解析出來以供更加方便的應用程式使用,同時也提供一些儲存上的介面,比如把PDU儲存到資料庫,從資料庫載入出PDU。
 

Class Purpose
PduPersister 用於管理PDU儲存
PduParser 用於解析PDU
PduComposer 用於產生PDU

PduPersister: 用於管理PDU儲存,關鍵的方法:

Return
Method
Description
PduPersister
getPduPersister(Context)
Get the object
Uri
persist(GenericPdu, Uri)
把一個GenericPdu儲存到Uri所指定的資料庫中,返回指向新產生資料的Uri
GenericPdu
load(Uri)
從資料庫把Uri所指的資料載入出來成一個GenericPdu對象
Uri
move(Uri, Uri)
把Pdu從一個地方移到另一個地方,比如從草稿箱移動到寄件匣,當MMS已發送時。

  

為什麼會要把PDU的儲存也封裝成PduPersister呢?因為PDU的儲存方式 是放在標準的SQLiteDatabase中,通過TelephonyProvider,而SQLiteDatabase中儲存不能以直接的PDU的位元組流來儲存,必須要把PDU拆解成為可讀的欄位,因此在儲存PDU和從儲存載入PDU的過程 中涉及到PDU資料上面的處理,因此封裝出來,更方便使用。


PduParser:用於把PDU位元組流解析成為Android可識別的GenericPdu

Return Method Description
PduParser PduParser(byte[]) Construct an object
GenericPdu parse() Parse the PDU byte stream into Android PDU GenericPdu

 

PduComposer:把GenericPdu打包產生PDU位元組流

Return Method Description
PduComposer PduComposer(Context, GenericPdu) Construct an object
byte[] make() Transfer the GenericPdu into a PDU byte stream

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.