2011-08-05 9 views

答えて

4

以下のコードは、MMSメッセージが表示されているとマークされているかどうかを更新するためのコードです。

SMSメッセージでこれを使用するには、次の「content:// mms /」をこの「content:// sms /」に置き換えます。

/** 
* Mark a single SMS/MMS message as being read or not. 
* 
* @param context - The current context of this Activity. 
* @param messageID - The Message ID that we want to alter. 
* 
* @return boolean - Returns true if the message was updated successfully. 
*/ 
public static boolean setMessageRead(Context context, long messageID, boolean isViewed){ 
    try{ 
     if(messageID == 0){ 
      return false; 
     } 
     ContentValues contentValues = new ContentValues(); 
     if(isViewed){ 
      contentValues.put("READ", 1); 
     }else{ 
      contentValues.put("READ", 0); 
     } 
     String selection = null; 
     String[] selectionArgs = null;   
     _context.getContentResolver().update(
       Uri.parse("content://mms/" + messageID), 
       contentValues, 
       selection, 
       selectionArgs); 
     return true; 
    }catch(Exception ex){ 
     return false; 
    } 
} 

また、あなたのアンドロイドマニフェストファイルにSMS権限の1つが必要な場合があります。

ハッピーコーディング:)

関連する問題