Android Question Service Notitfcations are not working anymore!

Discussion in 'Android Questions' started by Kbogle24, Feb 11, 2015.

  1. Kbogle24

    Kbogle24 Member Licensed 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?

    Code:
    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 * 1000True)
    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
     
  2. DonManfred

    DonManfred Expert Licensed User

    Which Version of android AND B4A are you using?
    Maybe this is of interest for this issue
     
  3. NJDude

    NJDude Expert Licensed User

    I don't see
    Code:
    n.Notify(1)
    anywhere in your code.
     
    DonManfred likes this.
  4. tigrot

    tigrot Well-Known Member Licensed 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!
     
  5. Kbogle24

    Kbogle24 Member Licensed 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.

    Code:
    #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
     
  6. NJDude

    NJDude Expert Licensed User

    Ok, what about this line:
    Code:
    n.Icon = "icon"
    You are missing that too.
     
  7. Kbogle24

    Kbogle24 Member Licensed User

    Thanks its fixed now. Don't know whats wrong with me... maybe I need some sleep.
     
  8. Kbogle24

    Kbogle24 Member Licensed User

    I sent you a small donation for your help.
     
  9. NJDude

    NJDude Expert Licensed User

    Thank you, I appreciate it.
     
    thedesolatesoul likes this.
Loading...
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice