Android Question Service Notitfcations are not working anymore!

Kbogle24

Member
Licensed User
Longtime User
I am not sure what happen... all i know is i haven't changed the code in over a year. I install the apk from a year ago and the notifications show up. When I compile the program again with the latest version of B4A the Service Notifications don't work. I hear the sound and it vibrates but nothing under notifications.

Here is my Service Code, I haven't changed it since last year. So it should be fine. Has something changed with B4A?

B4X:
Sub Process_Globals

Dim p As Phone
Dim pw As PhoneWakeState
Dim SayThis As String
Dim ReSec As Int
Dim EndSec As Int
Dim ReminderOn As Boolean
Dim TimeStarted As String
Dim DateStarted As String
Dim ReminderPause As Boolean
Dim VoiceInt As Int
Dim VibrateInt As Int
Dim SoundInt As Int
Dim ReHoursInt As Int
Dim ReMinInt As Int
Dim EndHoursInt As Int
Dim EndMinInt As Int
Dim Status As String
Status = "Stopped"
Dim n As Notification
Dim Test As Boolean
ReminderOn = False
ReminderPause= False  
EndMinInt = 2
ReMinInt = 1
SoundInt = 1
End Sub
Sub Service_Create


End Sub

Sub Service_Start (StartingIntent As Intent)
pw.PartialLock
n.Initialize
n.Icon = "sicon"
n.SetInfo("Procrastinator", "Reminder: " & SayThis , Main)
n.Sound = False
n.Light = True

Select VibrateInt
    Case 0
    n.Vibrate = True
    Case 1
    n.Vibrate = False
End Select

Select SoundInt
    Case 0
    n.sound = True
    Case 1
    n.sound = False
End Select

If ReminderPause = True Then
    PhoneState.Resume = True
    'ToastMessageShow ("Phone is being used. Reminder Pasued!",True)
    Return True
End If

If ReminderOn = True Then

    Service.StartForeground (2, n)
    If VoiceInt = 0 Then Main.TTS1.Speak (SayThis,True)
   
    StartServiceAt("", DateTime.Now + ReSec * 1000, True)
Else
n.SetInfo("Procrastinator", "Stopped" , Main)
   
   
    If VoiceInt = 0 Then Main.TTS1.Speak ("Your reminder has stopped.",True)
    Status = "Stopped"
    pw.ReleasePartialLock
    CallSub(Main,"Stop")
Service.StopForeground (1)
End If

End Sub

Sub Service_Destroy

End Sub
 

DonManfred

Expert
Licensed User
Longtime User
Which Version of android AND B4A are you using?
Maybe this is of interest for this issue
 
Upvote 0

tigrot

Well-Known Member
Licensed User
Longtime User
My beloved cat (died one year ago) was taking a walk on my PC keyboard while I was away. When I came back the program I was editing was horribly destroyed, but I didn't loose anything because of the daily copy I do on the net. Maybe Kbogle24 has a cat as well!
 
Upvote 0

Kbogle24

Member
Licensed User
Longtime User
Not sure why I didn't have n.Notify(1). But still wont work! I am using b4A 4.30 API 14 I have tried a few other API and still no luck. So to keep this simple I created a new service with just the notification. Still just hear the notification sound but no notification.

B4X:
#Region  Service Attributes
    #StartAtBoot: False
#End Region

Sub Process_Globals
    'These global variables will be declared once when the application starts.
    'These variables can be accessed from all modules.

End Sub
Sub Service_Create

End Sub

Sub Service_Start (StartingIntent As Intent)
Dim n As Notification
n.Initialize
n.SetInfo("Test Notification", "Test " , Main)
n.Sound = True
n.Light = True
n.Notify(1)
End Sub

Sub Service_Destroy

End Sub
 
Upvote 0
Top