Android Question how to refresh badger count on the button

Makumbi

Active Member
Licensed User
Please help i have used a badger count on my send button but my main problem is that it doesn't refresh to show the current count even when the old record has been deleted

B4X:
Dim j As HttpJob
    j.Initialize("", Me)
            j.Download($"http://kccug.com/Generic_Handler_JSON/RecieveSMSReply.ashx?customerId=${act}&s=${txtMessage.Text}&d=${DateTime.Date(l)}&id=${cod}&ph=${phone}&f=${sx}&tk=${Rsms4.Text}"$ )
    
            txtMessage.Text=""
            'Dim SQLQry As String = "DELETE FROM SMSlist where Phone = ?", Array As String(phone.Text))"
            'Starter.SQL1.ExecNonQuery(SQLQry)
            cursor1 =Starter.SQL1.ExecQuery2("DELETE  FROM  SMSlist where Atk = ?", Array As String(Rsms4.Text))
            badger1.Initialize
            Dim intCount As Int
            intCount = Starter.SQL1.ExecQuerySingleResult("SELECT count(Id) as Id FROM SMSlist")
            
            If intCount > 0 Then
                Dim ms As Int = intCount
            Else
                Dim ms As Int = 0
            End If
            Log(ms)
            badger1.SetBadge(btnSend, ms)
            
        Msgbox("SMS Sent Successfully ", "SMIS")
    End If
 

Attachments

Makumbi

Active Member
Licensed User
Please erel i have made some changes on my code but i didnt get you right please here are my changes
B4X:
    Dim j As HttpJob
    j.Initialize("", Me)
            j.Download($"http://kccug.com/Generic_Handler_JSON/RecieveSMSReply.ashx?customerId=${act}&s=${txtMessage.Text}&d=${DateTime.Date(l)}&id=${cod}&ph=${phone}&f=${sx}&tk=${Rsms4.Text}"$ )
    
            txtMessage.Text=""
            'Dim SQLQry As String = "DELETE FROM SMSlist where Phone = ?", Array As String(phone.Text))"
            'Starter.SQL1.ExecNonQuery(SQLQry)
            cursor1 =Starter.SQL1.ExecQuery2("DELETE  FROM  SMSlist where Atk = ?", Array As String(Rsms4.Text))
            badger1.Initialize
            Dim intCount As Int
            intCount = Starter.SQL1.ExecQuerySingleResult("SELECT count(Id) as Id FROM SMSlist")
            
            If intCount > 0 Then
                Dim ms As Int = intCount
            Else
                Dim ms As Int = 0
            End If
            Log(ms)
            badger1.SetBadge(btnSend, ms)
            
        MsgboxAsync("SMS Sent Successfully ", "SMIS")
Please help i have used a badger count on my send button but my main problem is that it doesn't refresh to show the current count even when the old record has been deleted

B4X:
Dim j As HttpJob
    j.Initialize("", Me)
            j.Download($"http://kccug.com/Generic_Handler_JSON/RecieveSMSReply.ashx?customerId=${act}&s=${txtMessage.Text}&d=${DateTime.Date(l)}&id=${cod}&ph=${phone}&f=${sx}&tk=${Rsms4.Text}"$ )
   
            txtMessage.Text=""
            'Dim SQLQry As String = "DELETE FROM SMSlist where Phone = ?", Array As String(phone.Text))"
            'Starter.SQL1.ExecNonQuery(SQLQry)
            cursor1 =Starter.SQL1.ExecQuery2("DELETE  FROM  SMSlist where Atk = ?", Array As String(Rsms4.Text))
            badger1.Initialize
            Dim intCount As Int
            intCount = Starter.SQL1.ExecQuerySingleResult("SELECT count(Id) as Id FROM SMSlist")
           
            If intCount > 0 Then
                Dim ms As Int = intCount
            Else
                Dim ms As Int = 0
            End If
            Log(ms)
            badger1.SetBadge(btnSend, ms)
           
        Msgbox("SMS Sent Successfully ", "SMIS")
    End If
 
Top