• 如果您觉得本站非常有看点,那么赶紧使用Ctrl+D 收藏吧

Java PendingMessages类的典型用法和代码示例

java 1次浏览

本文整理汇总了Java中android.provider.Telephony.MmsSms.PendingMessages的典型用法代码示例。如果您正苦于以下问题:Java PendingMessages类的具体用法?Java PendingMessages怎么用?Java PendingMessages使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。

PendingMessages类属于android.provider.Telephony.MmsSms包,在下文中一共展示了PendingMessages类的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: getPendingMessages

点赞 3

import android.provider.Telephony.MmsSms.PendingMessages; //导入依赖的package包/类
/**
 * Find all messages to be sent or downloaded before certain time.
 */
public Cursor getPendingMessages(long dueTime) {
    Uri.Builder uriBuilder = MessageDAO.MMS_PENDING_URI.buildUpon();
    uriBuilder.appendQueryParameter("protocol", "mms");

    String selection = PendingMessages.ERROR_TYPE + " < ?"
            + " AND " + PendingMessages.DUE_TIME + " <= ?";

    String[] selectionArgs = new String[] {
            String.valueOf(MmsSms.ERR_TYPE_GENERIC_PERMANENT),
            String.valueOf(dueTime)
    };

    return SqliteWrapper.query(mContext, mContentResolver,
            uriBuilder.build(), null, selection, selectionArgs,
            PendingMessages.DUE_TIME);
}
 

开发者ID:ivanovpv,
项目名称:darksms,
代码行数:20,
代码来源:PduPersister.java

示例2: markMmsFailedToSend

点赞 3

import android.provider.Telephony.MmsSms.PendingMessages; //导入依赖的package包/类
private void markMmsFailedToSend(Context context, Uri msgUri) {
    // https://github.com/qklabs/aosp-messenger/blob/master/src/com/android/mms/data/WorkingMessage.java#L1476-1476

    try {
        PduPersister p = PduPersister.getPduPersister(context);
        // Move the message into MMS Outbox. A trigger will create an entry in
        // the "pending_msgs" table.
        p.move(msgUri, Telephony.Mms.Outbox.CONTENT_URI);

        // Now update the pending_msgs table with an error for that new item.
        ContentValues values = new ContentValues(1);
        values.put(Telephony.MmsSms.PendingMessages.ERROR_TYPE, Telephony.MmsSms.ERR_TYPE_GENERIC_PERMANENT);
        long msgId = ContentUris.parseId(msgUri);
        SqliteWrapper.update(context, mContentResolver,
                Telephony.MmsSms.PendingMessages.CONTENT_URI,
                values, Telephony.MmsSms.PendingMessages.MSG_ID + "=" + msgId, null);
    } catch (MmsException e) {
        // Not much we can do here. If the p.move throws an exception, we'll just
        // leave the message in the draft box.
        Log.e(TAG, "Failed to move message to outbox and mark as error: " + msgUri, e);
    }
}
 

开发者ID:moezbhatti,
项目名称:qksms,
代码行数:23,
代码来源:RetryScheduler.java

示例3: markMmsMessageWithError

点赞 3

import android.provider.Telephony.MmsSms.PendingMessages; //导入依赖的package包/类
private void markMmsMessageWithError(Uri mmsUri) {
	try {
		PduPersister p = PduPersister.getPduPersister(mActivity);
		// Move the message into MMS Outbox. A trigger will create an entry
		// in
		// the "pending_msgs" table.
		p.move(mmsUri, Mms.Outbox.CONTENT_URI);

		// Now update the pending_msgs table with an error for that new
		// item.
		ContentValues values = new ContentValues(1);
		values.put(PendingMessages.ERROR_TYPE,
				MmsSms.ERR_TYPE_GENERIC_PERMANENT);
		long msgId = ContentUris.parseId(mmsUri);
		SqliteWrapper.update(mActivity, mContentResolver,
				PendingMessages.CONTENT_URI, values, PendingMessages.MSG_ID
						+ "=" + msgId, null);
	} catch (MmsException e) {
		// Not much we can do here. If the p.move throws an exception, we'll
		// just
		// leave the message in the draft box.
		Log.e(TAG, "Failed to move message to outbox and mark as error: "
				+ mmsUri, e);
	}
}
 

开发者ID:CommonQ,
项目名称:sms_DualCard,
代码行数:26,
代码来源:WorkingMessage.java

示例4: markMmsMessageWithError

点赞 3

import android.provider.Telephony.MmsSms.PendingMessages; //导入依赖的package包/类
private void markMmsMessageWithError(Uri mmsUri) {
    try {
        PduPersister p = PduPersister.getPduPersister(mActivity);
        // Move the message into MMS Outbox. A trigger will create an entry in
        // the "pending_msgs" table.
        p.move(mmsUri, Mms.Outbox.CONTENT_URI);

        // Now update the pending_msgs table with an error for that new item.
        ContentValues values = new ContentValues(1);
        values.put(PendingMessages.ERROR_TYPE, MmsSms.ERR_TYPE_GENERIC_PERMANENT);
        long msgId = ContentUris.parseId(mmsUri);
        SqliteWrapper.update(mActivity, mContentResolver,
                PendingMessages.CONTENT_URI,
                values, PendingMessages.MSG_ID + "=" + msgId, null);
    } catch (MmsException e) {
        // Not much we can do here. If the p.move throws an exception, we'll just
        // leave the message in the draft box.
        Log.e(TAG, "Failed to move message to outbox and mark as error: " + mmsUri, e);
    }
}
 

开发者ID:slvn,
项目名称:android-aosp-mms,
代码行数:21,
代码来源:WorkingMessage.java

示例5: setRetryAlarm

点赞 2

import android.provider.Telephony.MmsSms.PendingMessages; //导入依赖的package包/类
public static void setRetryAlarm(Context context) {
    Cursor cursor = PduPersister.getPduPersister(context).getPendingMessages(
            Long.MAX_VALUE);
    if (cursor != null) {
        try {
            if (cursor.moveToFirst()) {
                // The result of getPendingMessages() is order by due time.
                long retryAt = cursor.getLong(cursor.getColumnIndexOrThrow(
                        PendingMessages.DUE_TIME));

                Intent service = new Intent(
                        TransactionService.HANDLE_PENDING_TRANSACTIONS_ACTION, null, context,
                        TransactionService.class
                );
                PendingIntent operation = PendingIntent.getService(
                        context, 0, service, PendingIntent.FLAG_ONE_SHOT);
                AlarmManager am = (AlarmManager) context.getSystemService(
                        Context.ALARM_SERVICE);
                am.set(AlarmManager.RTC, retryAt, operation);

                if (LOCAL_LOGV) Log.v(TAG, "Next retry is scheduled at "
                            + (retryAt - System.currentTimeMillis()) + "ms from now");
            }
        } finally {
            cursor.close();
        }
    }
}
 

开发者ID:moezbhatti,
项目名称:qksms,
代码行数:29,
代码来源:RetryScheduler.java

示例6: getPendingMessages

点赞 2

import android.provider.Telephony.MmsSms.PendingMessages; //导入依赖的package包/类
/**
 * Find all messages to be sent or downloaded before certain time.
 */
public Cursor getPendingMessages(long dueTime) {
    Uri.Builder uriBuilder = PendingMessages.CONTENT_URI.buildUpon();
    uriBuilder.appendQueryParameter("protocol", "mms");
    String selection = PendingMessages.ERROR_TYPE + " < ?"
            + " AND " + PendingMessages.DUE_TIME + " <= ?";
    String[] selectionArgs = new String[] {
            String.valueOf(MmsSms.ERR_TYPE_GENERIC_PERMANENT),
            String.valueOf(dueTime)
    };
    return mContentResolver.query(
            uriBuilder.build(), null, selection, selectionArgs,
            PendingMessages.DUE_TIME);
}
 

开发者ID:Xlythe,
项目名称:AndroidTextManager,
代码行数:17,
代码来源:PduPersister.java

示例7: setRetryAlarm

点赞 2

import android.provider.Telephony.MmsSms.PendingMessages; //导入依赖的package包/类
public static void setRetryAlarm(Context context) {
    Cursor cursor = PduPersister.getPduPersister(context).getPendingMessages(
            Long.MAX_VALUE);
    if (cursor != null) {
        try {
            if (cursor.moveToFirst()) {
                // The result of getPendingMessages() is order by due time.
                long retryAt = cursor.getLong(cursor.getColumnIndexOrThrow(
                        PendingMessages.DUE_TIME));

                Intent service = new Intent(TransactionService.ACTION_ONALARM,
                                    null, context, TransactionService.class);
                PendingIntent operation = PendingIntent.getService(
                        context, 0, service, PendingIntent.FLAG_ONE_SHOT);
                AlarmManager am = (AlarmManager) context.getSystemService(
                        Context.ALARM_SERVICE);
                am.set(AlarmManager.RTC, retryAt, operation);

                if (Log.isLoggable(LogTag.TRANSACTION, Log.VERBOSE)) {
                    Log.v(TAG, "Next retry is scheduled at"
                            + (retryAt - System.currentTimeMillis()) + "ms from now");
                }
            }
        } finally {
            cursor.close();
        }
    }
}
 

开发者ID:CommonQ,
项目名称:sms_DualCard,
代码行数:29,
代码来源:RetryScheduler.java

示例8: sendMessage

点赞 2

import android.provider.Telephony.MmsSms.PendingMessages; //导入依赖的package包/类
public boolean sendMessage(long token) throws MmsException {
    // Load the MMS from the message uri
    if (Log.isLoggable(LogTag.APP, Log.VERBOSE)) {
        LogTag.debug("sendMessage uri: " + mMessageUri);
    }
    PduPersister p = PduPersister.getPduPersister(mContext);
    GenericPdu pdu = p.load(mMessageUri);

    if (pdu.getMessageType() != PduHeaders.MESSAGE_TYPE_SEND_REQ) {
        throw new MmsException("Invalid message: " + pdu.getMessageType());
    }

    SendReq sendReq = (SendReq) pdu;

    // Update headers.
    updatePreferencesHeaders(sendReq);

    // MessageClass.
    sendReq.setMessageClass(DEFAULT_MESSAGE_CLASS.getBytes());

    // Update the 'date' field of the message before sending it.
    sendReq.setDate(System.currentTimeMillis() / 1000L);

    sendReq.setMessageSize(mMessageSize);

    p.updateHeaders(mMessageUri, sendReq);

    long messageId = ContentUris.parseId(mMessageUri);

    // Move the message into MMS Outbox.
    if (!mMessageUri.toString().startsWith(Mms.Draft.CONTENT_URI.toString())) {
        // If the message is already in the outbox (most likely because we created a "primed"
        // message in the outbox when the user hit send), then we have to manually put an
        // entry in the pending_msgs table which is where TransacationService looks for
        // messages to send. Normally, the entry in pending_msgs is created by the trigger:
        // insert_mms_pending_on_update, when a message is moved from drafts to the outbox.
        ContentValues values = new ContentValues(7);

        values.put(PendingMessages.PROTO_TYPE, MmsSms.MMS_PROTO);
        values.put(PendingMessages.MSG_ID, messageId);
        values.put(PendingMessages.MSG_TYPE, pdu.getMessageType());
        values.put(PendingMessages.ERROR_TYPE, 0);
        values.put(PendingMessages.ERROR_CODE, 0);
        values.put(PendingMessages.RETRY_INDEX, 0);
        values.put(PendingMessages.DUE_TIME, 0);

        SqliteWrapper.insert(mContext, mContext.getContentResolver(),
                PendingMessages.CONTENT_URI, values);
    } else {
        p.move(mMessageUri, Mms.Outbox.CONTENT_URI);
    }

    // Start MMS transaction service
    SendingProgressTokenManager.put(messageId, token);
    if (MultiSimConfig.isMultiSimEnabled()) {
        Intent intent = new Intent(mContext, TransactionService.class);
        intent.putExtra(Mms.SUB_ID, ComposeMessageActivity.subSelected);
        Intent silentIntent = new Intent(mContext,
                edu.bupt.mms.ui.SelectMmsSubscription.class);
        silentIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
        silentIntent.putExtras(intent); //copy all extras
        mContext.startService(silentIntent);
    } else {
        mContext.startService(new Intent(mContext, TransactionService.class));
    }

    return true;
}
 

开发者ID:CommonQ,
项目名称:sms_DualCard,
代码行数:69,
代码来源:MmsMessageSender.java

示例9: sendMessage

点赞 2

import android.provider.Telephony.MmsSms.PendingMessages; //导入依赖的package包/类
public boolean sendMessage(long token) throws MmsException {
    // Load the MMS from the message uri
    if (Log.isLoggable(LogTag.APP, Log.VERBOSE)) {
        LogTag.debug("sendMessage uri: " + mMessageUri);
    }
    PduPersister p = PduPersister.getPduPersister(mContext);
    GenericPdu pdu = p.load(mMessageUri);

    if (pdu.getMessageType() != PduHeaders.MESSAGE_TYPE_SEND_REQ) {
        throw new MmsException("Invalid message: " + pdu.getMessageType());
    }

    SendReq sendReq = (SendReq) pdu;

    // Update headers.
    updatePreferencesHeaders(sendReq);

    // MessageClass.
    sendReq.setMessageClass(DEFAULT_MESSAGE_CLASS.getBytes());

    // Update the 'date' field of the message before sending it.
    sendReq.setDate(System.currentTimeMillis() / 1000L);

    sendReq.setMessageSize(mMessageSize);

    p.updateHeaders(mMessageUri, sendReq);

    long messageId = ContentUris.parseId(mMessageUri);

    // Move the message into MMS Outbox.
    if (!mMessageUri.toString().startsWith(Mms.Draft.CONTENT_URI.toString())) {
        // If the message is already in the outbox (most likely because we created a "primed"
        // message in the outbox when the user hit send), then we have to manually put an
        // entry in the pending_msgs table which is where TransacationService looks for
        // messages to send. Normally, the entry in pending_msgs is created by the trigger:
        // insert_mms_pending_on_update, when a message is moved from drafts to the outbox.
        ContentValues values = new ContentValues(7);

        values.put(PendingMessages.PROTO_TYPE, MmsSms.MMS_PROTO);
        values.put(PendingMessages.MSG_ID, messageId);
        values.put(PendingMessages.MSG_TYPE, pdu.getMessageType());
        values.put(PendingMessages.ERROR_TYPE, 0);
        values.put(PendingMessages.ERROR_CODE, 0);
        values.put(PendingMessages.RETRY_INDEX, 0);
        values.put(PendingMessages.DUE_TIME, 0);

        SqliteWrapper.insert(mContext, mContext.getContentResolver(),
                PendingMessages.CONTENT_URI, values);
    } else {
        p.move(mMessageUri, Mms.Outbox.CONTENT_URI);
    }

    // Start MMS transaction service
    SendingProgressTokenManager.put(messageId, token);
    mContext.startService(new Intent(mContext, TransactionService.class));

    return true;
}
 

开发者ID:slvn,
项目名称:android-aosp-mms,
代码行数:59,
代码来源:MmsMessageSender.java


版权声明:本文转自网络文章,转载此文章仅为分享知识,如有侵权,请联系管理员进行删除。
喜欢 (0)