当前位置: 首页>>代码示例>>Java>>正文


Java Mms类代码示例

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


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

示例1: move

import android.provider.Telephony.Mms; //导入依赖的package包/类
/**
 * Move a PDU object from one location to another.
 *
 * @param from Specify the PDU object to be moved.
 * @param to The destination location, should be one of the following:
 *        "content://mms/inbox", "content://mms/sent",
 *        "content://mms/drafts", "content://mms/outbox",
 *        "content://mms/trash".
 * @return New Uri of the moved PDU.
 * @throws MmsException Error occurred while moving the message.
 */
public Uri move(Uri from, Uri to) throws MmsException {
    // Check whether the 'msgId' has been assigned a valid value.
    long msgId = ContentUris.parseId(from);
    if (msgId == -1L) {
        throw new MmsException("Error! ID of the message: -1.");
    }

    // Get corresponding int value of destination box.
    Integer msgBox = MESSAGE_BOX_MAP.get(to);
    if (msgBox == null) {
        throw new MmsException(
                "Bad destination, must be one of "
                + "content://mms/inbox, content://mms/sent, "
                + "content://mms/drafts, content://mms/outbox, "
                + "content://mms/temp.");
    }

    ContentValues values = new ContentValues(1);
    values.put(Mms.MESSAGE_BOX, msgBox);
    SqliteWrapper.update(mContext, mContentResolver, from, values, null, null);
    return ContentUris.withAppendedId(to, msgId);
}
 
开发者ID:ivanovpv,项目名称:darksms,代码行数:34,代码来源:PduPersister.java

示例2: markMmsFailedToSend

import android.provider.Telephony.Mms; //导入依赖的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: getResponseStatus

import android.provider.Telephony.Mms; //导入依赖的package包/类
private int getResponseStatus(long msgID) {
    int respStatus = 0;
    Cursor cursor = SqliteWrapper.query(mContext, mContentResolver,
            Mms.Outbox.CONTENT_URI, null, Mms._ID + "=" + msgID, null, null);
    try {
        if (cursor.moveToFirst()) {
            respStatus = cursor.getInt(cursor.getColumnIndexOrThrow(Mms.RESPONSE_STATUS));
        }
    } finally {
        cursor.close();
    }
    if (respStatus != 0) {
        Log.e(TAG, "Response status is: " + respStatus);
    }
    return respStatus;
}
 
开发者ID:moezbhatti,项目名称:qksms,代码行数:17,代码来源:RetryScheduler.java

示例4: getRetrieveStatus

import android.provider.Telephony.Mms; //导入依赖的package包/类
private int getRetrieveStatus(long msgID) {
    int retrieveStatus = 0;
    Cursor cursor = SqliteWrapper.query(mContext, mContentResolver,
            Mms.Inbox.CONTENT_URI, null, Mms._ID + "=" + msgID, null, null);
    try {
        if (cursor.moveToFirst()) {
            retrieveStatus = cursor.getInt(cursor.getColumnIndexOrThrow(
                        Mms.RESPONSE_STATUS));
        }
    } finally {
        cursor.close();
    }
    if (retrieveStatus != 0) {
        if (LOCAL_LOGV) Log.v(TAG, "Retrieve status is: " + retrieveStatus);
    }
    return retrieveStatus;
}
 
开发者ID:moezbhatti,项目名称:qksms,代码行数:18,代码来源:RetryScheduler.java

示例5: startQueryHaveLockedMessages

import android.provider.Telephony.Mms; //导入依赖的package包/类
/**
 * Check for locked messages in all threads or a specified thread.
 *
 * @param handler   An AsyncQueryHandler that will receive onQueryComplete
 *                  upon completion of looking for locked messages
 * @param threadIds A list of threads to search. null means all threads
 * @param token     The token that will be passed to onQueryComplete
 */
public static void startQueryHaveLockedMessages(AsyncQueryHandler handler,
                                                Collection<Long> threadIds,
                                                int token) {
    handler.cancelOperation(token);
    Uri uri = MmsSms.CONTENT_LOCKED_URI;

    String selection = null;
    if (threadIds != null) {
        StringBuilder buf = new StringBuilder();
        int i = 0;

        for (long threadId : threadIds) {
            if (i++ > 0) {
                buf.append(" OR ");
            }
            // We have to build the selection arg into the selection because deep down in
            // provider, the function buildUnionSubQuery takes selectionArgs, but ignores it.
            buf.append(Mms.THREAD_ID).append("=").append(Long.toString(threadId));
        }
        selection = buf.toString();
    }
    handler.startQuery(token, threadIds, uri,
            ALL_THREADS_PROJECTION, selection, null, Conversations.DEFAULT_SORT_ORDER);
}
 
开发者ID:moezbhatti,项目名称:qksms,代码行数:33,代码来源:Conversation.java

示例6: saveRingtone

import android.provider.Telephony.Mms; //导入依赖的package包/类
/**
 * Copies media from an Mms to the DrmProvider
 *
 * @param context
 * @param msgId
 */
public static boolean saveRingtone(Context context, long msgId) {
    boolean result = true;
    PduBody body = null;
    try {
        body = SlideshowModel.getPduBody(context, ContentUris.withAppendedId(Mms.CONTENT_URI, msgId));
    } catch (MmsException e) {
        Log.e(TAG, "copyToDrmProvider can't load pdu body: " + msgId);
    }
    if (body == null) {
        return false;
    }

    int partNum = body.getPartsNum();
    for (int i = 0; i < partNum; i++) {
        PduPart part = body.getPart(i);
        String type = new String(part.getContentType());

        if (DrmUtils.isDrmType(type)) {
            // All parts (but there's probably only a single one) have to be successful
            // for a valid result.
            result &= copyPart(context, part, Long.toHexString(msgId));
        }
    }
    return result;
}
 
开发者ID:moezbhatti,项目名称:qksms,代码行数:32,代码来源:MessageUtils.java

示例7: copyMedia

import android.provider.Telephony.Mms; //导入依赖的package包/类
/**
 * Copies media from an Mms to the "download" directory on the SD card. If any of the parts
 * are audio types, drm'd or not, they're copied to the "Ringtones" directory.
 *
 * @param context
 * @param msgId
 */
public static boolean copyMedia(Context context, long msgId) {
    boolean result = true;
    PduBody body = null;
    try {
        body = SlideshowModel.getPduBody(context, ContentUris.withAppendedId(Mms.CONTENT_URI, msgId));
    } catch (MmsException e) {
        Log.e(TAG, "copyMedia can't load pdu body: " + msgId);
    }
    if (body == null) {
        return false;
    }

    int partNum = body.getPartsNum();
    for (int i = 0; i < partNum; i++) {
        PduPart part = body.getPart(i);

        // all parts have to be successful for a valid result.
        result &= copyPart(context, part, Long.toHexString(msgId));
    }
    return result;
}
 
开发者ID:moezbhatti,项目名称:qksms,代码行数:29,代码来源:MessageUtils.java

示例8: isForwardable

import android.provider.Telephony.Mms; //导入依赖的package包/类
/**
 * Returns true if all drm'd parts are forwardable.
 *
 * @param context
 * @param msgId
 * @return true if all drm'd parts are forwardable.
 */
public static boolean isForwardable(Context context, long msgId) {
    PduBody body = null;
    try {
        body = SlideshowModel.getPduBody(context, ContentUris.withAppendedId(Mms.CONTENT_URI, msgId));
    } catch (MmsException e) {
        Log.e(TAG, "getDrmMimeType can't load pdu body: " + msgId);
    }
    if (body == null) {
        return false;
    }

    int partNum = body.getPartsNum();
    for (int i = 0; i < partNum; i++) {
        PduPart part = body.getPart(i);
        String type = new String(part.getContentType());

        if (DrmUtils.isDrmType(type) && !DrmUtils.haveRightsForAction(part.getDataUri(),
                DrmStore.Action.TRANSFER)) {
            return false;
        }
    }
    return true;
}
 
开发者ID:moezbhatti,项目名称:qksms,代码行数:31,代码来源:MessageUtils.java

示例9: lockMessage

import android.provider.Telephony.Mms; //导入依赖的package包/类
public static void lockMessage(Context context, MessageItem msgItem, boolean locked) {
    Uri uri;
    if ("sms".equals(msgItem.mType)) {
        uri = Sms.CONTENT_URI;
    } else {
        uri = Mms.CONTENT_URI;
    }
    final Uri lockUri = ContentUris.withAppendedId(uri, msgItem.mMsgId);

    final ContentValues values = new ContentValues(1);
    values.put("locked", locked ? 1 : 0);

    new Thread(() -> {
        context.getContentResolver().update(lockUri,
                values, null, null);
    }, "MainActivity.lockMessage").start();
}
 
开发者ID:moezbhatti,项目名称:qksms,代码行数:18,代码来源:MessageUtils.java

示例10: move

import android.provider.Telephony.Mms; //导入依赖的package包/类
/**
 * Move a PDU object from one location to another.
 *
 * @param from Specify the PDU object to be moved.
 * @param to The destination location, should be one of the following:
 *        "content://mms/inbox", "content://mms/sent",
 *        "content://mms/drafts", "content://mms/outbox",
 *        "content://mms/trash".
 * @return New Uri of the moved PDU.
 * @throws MmsException Error occurred while moving the message.
 */
public Uri move(Uri from, Uri to) throws MmsException {
    // Check whether the 'msgId' has been assigned a valid value.
    long msgId = ContentUris.parseId(from);
    if (msgId == -1L) {
        throw new MmsException("Error! ID of the message: -1.");
    }
    // Get corresponding int value of destination box.
    Integer msgBox = MESSAGE_BOX_MAP.get(to);
    if (msgBox == null) {
        throw new MmsException(
                "Bad destination, must be one of "
                        + "content://mms/inbox, content://mms/sent, "
                        + "content://mms/drafts, content://mms/outbox, "
                        + "content://mms/temp.");
    }
    ContentValues values = new ContentValues(1);
    values.put(Mms.MESSAGE_BOX, msgBox);
    mContentResolver.update(from, values, null, null);
    return ContentUris.withAppendedId(to, msgId);
}
 
开发者ID:Xlythe,项目名称:AndroidTextManager,代码行数:32,代码来源:PduPersister.java

示例11: getRetrieveStatus

import android.provider.Telephony.Mms; //导入依赖的package包/类
private int getRetrieveStatus(long msgID) {
    int retrieveStatus = 0;
    Cursor cursor = SqliteWrapper.query(mContext, mContentResolver,
            Mms.Inbox.CONTENT_URI, null, Mms._ID + "=" + msgID, null, null);
    try {
        if (cursor.moveToFirst()) {
            retrieveStatus = cursor.getInt(cursor.getColumnIndexOrThrow(
                        Mms.RESPONSE_STATUS));
        }
    } finally {
        cursor.close();
    }
    if (retrieveStatus != 0) {
        if (Log.isLoggable(LogTag.TRANSACTION, Log.VERBOSE)) {
            Log.v(TAG, "Retrieve status is: " + retrieveStatus);
        }
    }
    return retrieveStatus;
}
 
开发者ID:CommonQ,项目名称:sms_DualCard,代码行数:20,代码来源:RetryScheduler.java

示例12: isDuplicateNotification

import android.provider.Telephony.Mms; //导入依赖的package包/类
private static boolean isDuplicateNotification(
        Context context, NotificationInd nInd) {
    byte[] rawLocation = nInd.getContentLocation();
    if (rawLocation != null) {
        String location = new String(rawLocation);
        String selection = Mms.CONTENT_LOCATION + " = ?";
        String[] selectionArgs = new String[] { location };
        Cursor cursor = SqliteWrapper.query(
                context, context.getContentResolver(),
                Mms.CONTENT_URI, new String[] { Mms._ID },
                selection, selectionArgs, null);
        if (cursor != null) {
            try {
                if (cursor.getCount() > 0) {
                    // We already received the same notification before.
                    return true;
                }
            } finally {
                cursor.close();
            }
        }
    }
    return false;
}
 
开发者ID:CommonQ,项目名称:sms_DualCard,代码行数:25,代码来源:PushReceiver.java

示例13: getDownloadFailedMessageCount

import android.provider.Telephony.Mms; //导入依赖的package包/类
private static int getDownloadFailedMessageCount(Context context) {
    // Look for any messages in the MMS Inbox that are of the type
    // NOTIFICATION_IND (i.e. not already downloaded) and in the
    // permanent failure state.  If there are none, cancel any
    // failed download notification.
    Cursor c = SqliteWrapper.query(context, context.getContentResolver(),
            Mms.Inbox.CONTENT_URI, null,
            Mms.MESSAGE_TYPE + "=" +
                String.valueOf(PduHeaders.MESSAGE_TYPE_NOTIFICATION_IND) +
            " AND " + Mms.STATUS + "=" +
                String.valueOf(DownloadManager.STATE_PERMANENT_FAILURE),
            null, null);
    if (c == null) {
        return 0;
    }
    int count = c.getCount();
    c.close();
    return count;
}
 
开发者ID:CommonQ,项目名称:sms_DualCard,代码行数:20,代码来源:MessagingNotification.java

示例14: getThreadId

import android.provider.Telephony.Mms; //导入依赖的package包/类
/**
 * Get the thread ID of the MMS message with the given URI
 * @param context The context
 * @param uri The URI of the SMS message
 * @return The thread ID, or THREAD_NONE if the URI contains no entries
 */
public static long getThreadId(Context context, Uri uri) {
    Cursor cursor = SqliteWrapper.query(
            context,
            context.getContentResolver(),
            uri,
            MMS_THREAD_ID_PROJECTION,
            null,
            null,
            null);

    if (cursor == null) {
        return THREAD_NONE;
    }

    try {
        if (cursor.moveToFirst()) {
            return cursor.getLong(cursor.getColumnIndex(Mms.THREAD_ID));
        } else {
            return THREAD_NONE;
        }
    } finally {
        cursor.close();
    }
}
 
开发者ID:CommonQ,项目名称:sms_DualCard,代码行数:31,代码来源:MessagingNotification.java

示例15: getSubIdFromDb

import android.provider.Telephony.Mms; //导入依赖的package包/类
private int getSubIdFromDb(Uri uri) {
    int subId = 0;
    Cursor c = getApplicationContext().getContentResolver().query(uri,
            null, null, null, null);
    Log.d(TAG, "Cursor= "+DatabaseUtils.dumpCursorToString(c));
    if (c != null) {
        try {
            if (c.moveToFirst()) {
                subId = c.getInt(c.getColumnIndex(Mms.SUB_ID));
                Log.d(TAG, "subId in db="+subId );
                return subId;
            }
        } finally {
            c.close();
        }
    }
    return subId;

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


注:本文中的android.provider.Telephony.Mms类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。