在应用程序图标android中显示未读消息计数

时间:2013-01-15 12:39:37

标签: android messaging

How to implement unread message notification in our app like in messaging?

如何在我们的应用中实现未读消息通知,如消息(图片中)?

任何帮助表示赞赏

1 个答案:

答案 0 :(得分:-2)

public int getNumberOfUnreadMessages(Context context) {

   final Uri SMS_INBOX_URI = Uri.parse("content://sms/inbox");
   Cursor inboxCursor = context.getContentResolver().query(SMS_INBOX_URI, null, "read =  
    0", null, null);
   int unreadMessagesCount = inboxCursor.getCount();
   inboxCursor.close();
   return unreadMessagesCount;
   }