如何在我们的应用程序中实现未读消息通知,如消息(如图)?
任何帮助表示赞赏
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;
}