use of com.google.android.mms.pdu_alt.ReadRecInd in project qksms by moezbhatti.
the class MmsMessageSender method sendReadRec.
public static void sendReadRec(Context context, String to, String messageId, int status) {
EncodedStringValue[] sender = new EncodedStringValue[1];
sender[0] = new EncodedStringValue(to);
try {
final ReadRecInd readRec = new ReadRecInd(new EncodedStringValue(PduHeaders.FROM_INSERT_ADDRESS_TOKEN_STR.getBytes()), messageId.getBytes(), PduHeaders.CURRENT_MMS_VERSION, status, sender);
readRec.setDate(System.currentTimeMillis() / 1000);
boolean group;
try {
group = com.moez.QKSMS.mmssms.Transaction.settings.getGroup();
} catch (Exception e) {
group = PreferenceManager.getDefaultSharedPreferences(context).getBoolean("pref_key_compose_group", true);
}
PduPersister.getPduPersister(context).persist(readRec, Uri.parse("content://mms/outbox"), true, group, null);
Intent service = new Intent(TransactionService.HANDLE_PENDING_TRANSACTIONS_ACTION, null, context, TransactionService.class);
context.startService(service);
} catch (InvalidHeaderValueException e) {
Log.e(TAG, "Invalide header value", e);
} catch (MmsException e) {
Log.e(TAG, "Persist message failed", e);
}
}
use of com.google.android.mms.pdu_alt.ReadRecInd in project qksms by moezbhatti.
the class ReadRecTransaction method run.
public void run() {
PduPersister persister = PduPersister.getPduPersister(mContext);
try {
// Load M-read-rec.ind from outbox
ReadRecInd readRecInd = (ReadRecInd) persister.load(mReadReportURI);
// insert the 'from' address per spec
String lineNumber = Utils.getMyPhoneNumber(mContext);
readRecInd.setFrom(new EncodedStringValue(lineNumber));
// Pack M-read-rec.ind and send it
byte[] postingData = new PduComposer(mContext, readRecInd).make();
sendPdu(postingData);
Uri uri = persister.move(mReadReportURI, Sent.CONTENT_URI);
mTransactionState.setState(TransactionState.SUCCESS);
mTransactionState.setContentUri(uri);
} catch (IOException e) {
if (LOCAL_LOGV) {
Timber.v(e, "Failed to send M-Read-Rec.Ind.");
}
} catch (MmsException e) {
if (LOCAL_LOGV) {
Timber.v(e, "Failed to load message from Outbox.");
}
} catch (RuntimeException e) {
if (LOCAL_LOGV) {
Timber.e(e, "Unexpected RuntimeException.");
}
} finally {
if (mTransactionState.getState() != TransactionState.SUCCESS) {
mTransactionState.setState(TransactionState.FAILED);
mTransactionState.setContentUri(mReadReportURI);
}
notifyObservers();
}
}
Aggregations