Android之多媒體訊息學習記錄1

來源:互聯網
上載者:User

當接收一條多媒體訊息時,首先會從多媒體訊息中心收到一條push資訊,PushReciever.java的OnReceive()方法被觸發,接著會執行ReceivePushTask的doInbackground()方法,在該方法裡,會擷取raw push-pdu 資訊,解析並存入到資料庫中(pdu表)中。這時會把多媒體訊息的date欄位和expir欄位加到資料庫中,然後執行TransactionService服務。

    

    NotificationTransaction.java類的run()方法負責從多媒體訊息中心下載多媒體訊息資訊

    byte[] retrieveConfData = null;

            // We should catch exceptions here to response MMSC

            // with STATUS_DEFERRED.

            try {

                retrieveConfData = getPdu(mContentLocation);

            } catch (IOException e) {

                mTransactionState.setState(FAILED);

            }

    擷取到資料後,解析資料並存入資料庫中,然後刪除之前加入到資料庫中的那條記錄。

     if (retrieveConfData != null) {

// BEGIN: 0001893 bggim@lge.com 2009-11-11

// MOD: 0001893: [MMS] Apply LGDRM code (From EVE)

             //BEGIN : 0002820 byeonggeun.kim@lge.com 09-12-28

             //ADD : 0002820: [MMS] Fix MMS time stamp bug

             RetrieveConf pdu =(RetrieveConf) new PduParser(retrieveConfData).parse(mContext);

             //END : 0002820 byeonggeun.kim@lge.com 09-12-28

// END: 0001893 bggim@lge.com 2009-11-11

                if ((pdu == null) || (pdu.getMessageType() != MESSAGE_TYPE_RETRIEVE_CONF)) {

                    Log.e(TAG, "Invalid M-RETRIEVE.CONF PDU.");

                    mTransactionState.setState(FAILED);

                    status = STATUS_UNRECOGNIZED;

                } else {

                    // Save the received PDU (must be a M-RETRIEVE.CONF).

                    PduPersister p = PduPersister.getPduPersister(mContext);

                    Log.e("xxxx", "Date ============== " + pdu.getDate());

                    Date now = new Date();

                    long l = now.getTime()/1000;

//                    pdu.setDate(System.currentTimeMillis());//add by chenrx

                    pdu.setDate(l);//add by chenrx

                    Log.e("xxxx", "Date ====modify======== " + pdu.getDate());

                    

                    Uri uri = p.persist(pdu, Inbox.CONTENT_URI);

                    // We have successfully downloaded the new MM. Delete the

                    // M-NotifyResp.ind from Inbox.

                    SqliteWrapper.delete(mContext, mContext.getContentResolver(),

                                         mUri, null, null);

                    // Notify observers with newly received MM.

                    mUri = uri;

                    status = STATUS_RETRIEVED;

                }

            }

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在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.