Hi everyone, I have a problem, my app must perform background monitoring of numbers sent from another device to a host on my website, my app every 3 seconds queries the website displaying one of the 4 numbers in the my website folder, as soon as one of these numbers matches the number stored in the app, it should wake up from the background and play alerting even to the corresponding number, everything seems to work perfectly for the first few minutes even in the background, but after a while seems to be no longer active as if it were killed, yet the notification is always present on the phone, if I click on the notification, the app reopens regularly but no longer alerts me if one of the numbers matches the one stored in my app. Where I'm wrong and above all how do I get the app always awake in the background, I'll post the service module to see if I'm wrong.
	
	
	
	
	
	
	
		
			
			
			
			
			
		
	
	
	
		
	
	
		
	
please help me, this important for me.
			
			
			
				B4X:
			
		
		
		#Region  Service Attributes
    #StartAtBoot: True
    #StartCommandReturnValue: android.app.Service.START_STICKY
#End Region
Sub Process_Globals
    'These global variables will be declared once when the application starts.
    'These variables can be accessed from all modules.
    
    
    Dim N As Notification
    Dim hc As     OkHttpClient
    Dim testo As String
    Dim timer1 As Timer
    Dim timer2 As Timer
    Dim timer3 As Timer
    Dim timer4 As Timer
    Dim risultatoA As String
    Dim risultatoB As String
    Dim risultatoC As String
    Dim risultatoD As String
    
End Sub
Sub Service_Create
    n.Initialize
    n.Icon = "icon"
    n.Sound = False
    n.Vibrate = False
    n.Light = False
    n.OnGoingEvent=True
    n.SetInfo("Turn And Go","Numero prenotato " &  Main.chiamataA & " " & Main.chiamataB & " " & Main.chiamataC & " " & Main.chiamataD ,Main)
    n.Notify(1)
    hc.Initialize("hc")
    timer1.Initialize("timer1",3000)
    timer2.Initialize("timer2",3000)
    timer3.Initialize("timer3",3000)
    timer4.Initialize("timer4",3000)
    
    timer1.Enabled=True
    timer2.Enabled=True
    timer3.Enabled=True
    timer4.Enabled=True
    
    
End Sub
Sub Service_Start (StartingIntent As Intent)
    
    Service.StartForeground(1,n)   
    StartServiceAt(Me, DateTime.Now + 30 * DateTime.TicksPerMinute, True)
    risultatoA = Main.chiamataA
    risultatoB = Main.chiamataB
    risultatoC = Main.chiamataC
    risultatoD = Main.chiamataD
End Sub
Sub timer1_Tick
    Log("sono sulla sub timer1 di Starter")
    Dim job As HttpJob
    job.Initialize("Job", Me)
    job.Download("http://www.xxxxx.xxx/xxxxxx/"& Main.linea & "/NumeroA.txt")
    
End Sub
Sub timer2_Tick
    Log("sono sulla sub timer2 di Starter")
    Dim job As HttpJob
    job.Initialize("Job", Me)
    job.Download("http://www.xxxxx.xxx/xxxxxx/"& Main.linea & "/NumeroB.txt")
        
End Sub
Sub timer3_Tick
    Log("sono sulla sub timer3")
    Dim job As HttpJob
    job.Initialize("Job", Me)
    job.Download("http://www.xxxxx.xxx/xxxxxx/"& Main.linea & "/NumeroC.txt")
        
End Sub
Sub timer4_Tick
    Log("sono sulla sub timer4")
    Dim job As HttpJob
    job.Initialize("Job", Me)
    job.Download("http://www.siciliashop.xxx/xxxxxx/"& Main.linea & "/NumeroD.txt")
        
End Sub
Sub JobDone (job As HttpJob)
    
    Log("JobName = " & job.JobName & ", Success = " & job.Success)
    If job.Success = True Then
        Select job.JobName
            Case "Job" , "job2"
                'print the result to the logs
                
                testo =job.GetString
                Log(job.GetString)
                If testo.StartsWith("A") Then
                    
                    Log("su starter nel job " & risultatoA)
                    If  job.GetString = risultatoA  Then
                        Log("ok result")
                        
                        StartActivity(avviso)
                        
                    End If
                else if testo.StartsWith("B") Then
                    
                    If  job.GetString = risultatoB  Then
                        Log("ok result")
                        
                        StartActivity(avviso)
                    End If
                    
                else if testo.StartsWith("C") Then
                    
                    If  job.GetString = risultatoC  Then
                        Log("ok result")
                        
                        StartActivity(avviso)
                    End If
                    
                else if testo.StartsWith("D") Then
                    
                    If  job.GetString = risultatoD  Then
                        Log("ok result")
                        
                        StartActivity(avviso)
                    End If
                End If
        
            Case "Job3"
                'show the downloaded image
                'Activity.SetBackgroundImage(job.GetBitmap)
        End Select
    Else
        Log("Error: " & job.ErrorMessage)
        'ToastMessageShow("Error: " & job.ErrorMessage, True)
    End If
    job.Release
    
End Sub
Sub testo_TextChanged (Old As String, New As String)
    If testo = Old Then
        
    Else
        Log("vai sulla sub Creafile")
    End If
End Sub
Sub Service_Destroy
    n.Cancel(1)
End Sub
perchè non rimane attivo comeplease help me, this important for me.
 
				 
 
		 
 
		 
 
		 
 
		 
 
		