Android Question Notification

Discussion in 'Android Questions' started by guido valentino, Jun 17, 2015.

  1. guido valentino

    guido valentino Member Licensed User

    Hi, is there a way to send a notification after a tot of time even if the application is closed? for example, to alert the user that something it is recharged:) thanks
     
  2. lemonisdead

    lemonisdead Well-Known Member Licensed User

    Hello,
    Yes using a service. You will initialize the notification from it. The point you will have to think about is the activity shown if the user clicks on the notification itself.
     
    mangojack likes this.
  3. guido valentino

    guido valentino Member Licensed User

    Thanks :) but what service?
     
  4. lemonisdead

    lemonisdead Well-Known Member Licensed User

  5. guido valentino

    guido valentino Member Licensed User

    I want send a notification also when the app iso closed. No in background but close :)
     
  6. lemonisdead

    lemonisdead Well-Known Member Licensed User

    So the service is the way to go. Give it a try :)
     
  7. guido valentino

    guido valentino Member Licensed User

    Yes i see, infact the notification works. But only when i close the app and this remains in background. If i kill the app notifications don t work
     
  8. lemonisdead

    lemonisdead Well-Known Member Licensed User

    would you post your code ? Perhaps do You kill the app manully so you kill the service too ?
     
  9. guido valentino

    guido valentino Member Licensed User

    for example
    - In Main
    Code:
    Sub btnCreateNotifications_Click
        
    StartService(notifica)
       
    End Sub
    -In Notifica
    Code:
    #Region  Service Attributes 
        
    #StartAtBoot: False
    #End Region

    Sub Process_Globals
        
    Dim timer1 As Timer
    End Sub
    Sub Service_Create
    timer1.Initialize(
    "timer1",7000)
    End Sub

    Sub Service_Start (StartingIntent As Intent)
        timer1.Enabled=
    True
    End Sub

    Sub Service_Destroy

    End Sub
    Sub timer1_tick
            
    Dim n As Notification
            n.Initialize
            n.SetInfo(
    "Notification " & 1"abcde", Me)
            n.Icon = 
    "icon"
            n.Notify(
    1)
            timer1.Enabled=
    False
    End Sub
     
  10. lemonisdead

    lemonisdead Well-Known Member Licensed User

    perhaps do You want to restart the service when you stop the app ? If yes, you could try to insert a
    StartServiceAt in Service_Destroy ?
     
  11. DonManfred

    DonManfred Expert Licensed User

    An app which is killed CANNOT show any more notifications... The app is NOT running.
     
    lemonisdead likes this.
Loading...