Example usage for android.telephony SmsManager sendMultimediaMessage

List of usage examples for android.telephony SmsManager sendMultimediaMessage

Introduction

In this page you can find the example usage for android.telephony SmsManager sendMultimediaMessage.

Prototype

public void sendMultimediaMessage(Context context, Uri contentUri, String locationUrl, Bundle configOverrides,
        PendingIntent sentIntent) 

Source Link

Document

Send an MMS message

Note: This method will never trigger an SMS disambiguation dialog.

Usage

From source file:com.android.mms.transaction.NotificationTransaction.java

public void sendNotifyRespInd(int status) {
    MmsLog.i(MmsApp.TXN_TAG, "NotificationTransaction: sendNotifyRespInd()");
    // Create the M-NotifyResp.ind
    NotifyRespInd notifyRespInd = null;// ww  w  .  j a va 2 s  .  co m
    try {
        notifyRespInd = new NotifyRespInd(PduHeaders.CURRENT_MMS_VERSION, mNotificationInd.getTransactionId(),
                status);
    } catch (InvalidHeaderValueException ex) {
        ex.printStackTrace();
        return;
    }

    /// M:Code analyze 014, this paragraph below is using for judging if it is allowed
    /// to send delivery report,at present,we don't support delivery report in MMS @{
    mOpNotificationTransactionExt.sendNotifyRespInd(mContext, mSubId, notifyRespInd);

    byte[] datas = new PduComposer(mContext, notifyRespInd).make();
    File pduFile = createPduFile(datas, NOTIFY_RESP_NAME + mUri.getLastPathSegment());
    if (pduFile == null) {
        return;
    }

    SmsManager manager = SmsManager.getSmsManagerForSubscriptionId(mSubId);
    /*
    Intent intent = new Intent(TransactionService.ACTION_TRANSACION_PROCESSED);
    intent.putExtra(PhoneConstants.SUBSCRIPTION_KEY, mSubId);
    // intent.putExtra(TransactionBundle.URI, mUri.toString());
    PendingIntent sentIntent = PendingIntent.getBroadcast(mContext, 0, intent,
        PendingIntent.FLAG_UPDATE_CURRENT);
        */
    // Pack M-NotifyResp.ind and send it
    Uri pduFileUri = FileProvider.getUriForFile(mContext, MMS_FILE_PROVIDER_AUTHORITIES, pduFile);
    if (MmsConfig.getNotifyWapMMSC()) {
        manager.sendMultimediaMessage(mContext, pduFileUri, mContentLocation, null, null);
    } else {
        manager.sendMultimediaMessage(mContext, pduFileUri, null, null, null);
    }
}

From source file:com.android.mms.transaction.RetrieveTransaction.java

private void sendNotifyRespInd(int status) {
    MmsLog.i(MmsApp.TXN_TAG, "RetrieveTransaction: sendNotifyRespInd()");
    // Create the M-NotifyResp.ind
    try {//w w  w .j  ava  2s .c o m
        NotificationInd notificationInd = (NotificationInd) PduPersister.getPduPersister(mContext).load(mUri);

        NotifyRespInd notifyRespInd = null;
        try {
            notifyRespInd = new NotifyRespInd(PduHeaders.CURRENT_MMS_VERSION,
                    notificationInd.getTransactionId(), status);
        } catch (InvalidHeaderValueException ex) {
            ex.printStackTrace();
            return;
        }
        byte[] datas = new PduComposer(mContext, notifyRespInd).make();
        File pduFile = createPduFile(datas, NOTIFY_RESP_NAME + mUri.getLastPathSegment());
        if (pduFile == null) {
            return;
        }

        SmsManager manager = SmsManager.getSmsManagerForSubscriptionId(mSubId);
        /*
        Intent intent = new Intent(TransactionService.ACTION_TRANSACION_PROCESSED);
        intent.putExtra(PhoneConstants.SUBSCRIPTION_KEY, mSubId);
        // intent.putExtra(TransactionBundle.URI, mUri.toString());
        PendingIntent sentIntent = PendingIntent.getBroadcast(mContext, 0, intent,
            PendingIntent.FLAG_UPDATE_CURRENT);
            */
        // Pack M-NotifyResp.ind and send it
        Uri pduFileUri = FileProvider.getUriForFile(mContext, MMS_FILE_PROVIDER_AUTHORITIES, pduFile);
        if (MmsConfig.getNotifyWapMMSC()) {
            manager.sendMultimediaMessage(mContext, pduFileUri, mContentLocation, null, null);
        } else {
            manager.sendMultimediaMessage(mContext, pduFileUri, null, null, null);
        }
    } catch (Throwable t) {
        Log.e(TAG, Log.getStackTraceString(t));
    }
}

From source file:com.android.mms.transaction.RetrieveTransaction.java

public void sendAcknowledgeInd() {
    if (mMessageUri == null) {
        MmsLog.w(MmsApp.TXN_TAG, "RetrieveTransaction: mMessageUri is null");
        return;// w w  w  .  j av  a  2  s . c o m
    }
    // Send M-Acknowledge.ind to MMSC if required.
    // If the Transaction-ID isn't set in the M-Retrieve.conf, it means
    // the MMS proxy-relay doesn't require an ACK.
    MmsLog.i(MmsApp.TXN_TAG, "RetrieveTransaction: sendAcknowledgeInd()");
    try {
        Uri uri = Uri.parse(mMessageUri);
        PduPersister persister = PduPersister.getPduPersister(mContext);
        RetrieveConf retrieveConf = null;

        retrieveConf = (RetrieveConf) persister.load(uri);

        byte[] tranId = retrieveConf.getTransactionId();
        if (tranId != null) {
            // Create M-Acknowledge.ind
            AcknowledgeInd acknowledgeInd = new AcknowledgeInd(PduHeaders.CURRENT_MMS_VERSION, tranId);

            // insert the 'from' address per spec
            String lineNumber = MessageUtils.getLocalNumber(mSubId);
            if (lineNumber != null) {
                acknowledgeInd.setFrom(new EncodedStringValue(lineNumber));
            } else {
                MmsLog.d(MmsApp.TXN_TAG, "getLocalNumber(" + mSubId + "),return null");
            }

            /// M:Code analyze 012,add for new feature,judge if it is allowed
            /// to send delivery report for acknowledgeInd transaction @{
            /// M: modify for MmsPreference Plugin @{
            mOpRetrieveTransactionExt.sendAcknowledgeInd(mContext, mSubId, acknowledgeInd);
            /// @}

            byte[] datas = new PduComposer(mContext, acknowledgeInd).make();
            File pduFile = createPduFile(datas, ACK_RESP_NAME + mUri.getLastPathSegment());
            if (pduFile == null) {
                return;
            }

            SmsManager manager = SmsManager.getSmsManagerForSubscriptionId(mSubId);
            /*
            Intent intent = new Intent(TransactionService.ACTION_TRANSACION_PROCESSED);
            intent.putExtra(PhoneConstants.SUBSCRIPTION_KEY, mSubId);
            // intent.putExtra(TransactionBundle.URI, mUri.toString());
            PendingIntent sentIntent = PendingIntent.getBroadcast(mContext, 0, intent,
                PendingIntent.FLAG_UPDATE_CURRENT);
                */
            // Pack M-NotifyResp.ind and send it
            Uri pduFileUri = FileProvider.getUriForFile(mContext, MMS_FILE_PROVIDER_AUTHORITIES, pduFile);
            if (MmsConfig.getNotifyWapMMSC()) {
                manager.sendMultimediaMessage(mContext, pduFileUri, mContentLocation, null, null);
            } else {
                manager.sendMultimediaMessage(mContext, pduFileUri, null, null, null);
            }
        }
    } catch (MmsException ex) {
        ex.printStackTrace();
    }
}