Android Question Gmail , WhatsApp , messages in queue. alert to user

Daniel-White

Active Member
Licensed User
Longtime User
Hi folks. I have the big curiosity, how Gmail, WhatsApp and so on, can show the messages in queue.? An example the next figures show it. How by code these programs can add the number like WhatsAPP the number 1 ,etc. and tell to end user he has one or two etc messages waiting to read.?
Thanks you

upload_2015-12-19_18-45-50.png
 

Ohanian

Active Member
Licensed User
Longtime User
Hi,

this code works on Samsung devices :

Mainfest :

B4X:
AddPermission("com.sec.android.provider.badge.permission.READ")
AddPermission("com.sec.android.provider.badge.permission.WRITE")

B4X:
Private cr As ContentResolver

Try
                                    Dim cv As ContentValues
                                    cv.Initialize
                                    cv.PutString("package", "PACKAGENAME")
                                    cv.PutString("class", "PACKAGENAME.main")
                                    cv.PutInteger("badgecount", iCount)
                                    Dim u As Uri
                                    u.Parse("content://com.sec.badge/apps")
                                    cr.Insert(u, cv)
                                Catch
                               
                                End Try

Clear :
B4X:
Private cr As ContentResolver

Try
        Dim cv As ContentValues
        cv.Initialize
        cv.PutString("package", "PACKAGENAME")
        cv.PutString("class", "PACKAGENAME.main")
        cv.PutInteger("badgecount", 0)
        Dim u As Uri
        u.Parse("content://com.sec.badge/apps")
        cr.Update(u, cv, "", Null)
    Catch
   
    End Try
 
Upvote 0
Top