Notifications do not occur unless the app is open in the foreground.
I have researched the forum and can't find a fix for this.
Thanks again for the assistance!
	
	
	
	
	
	
	
		
			
			
			
			
			
		
	
	
	
		
	
	
		
	
			
			I have researched the forum and can't find a fix for this.
Thanks again for the assistance!
			
				Tracker service:
			
		
		
		#Region  Service Attributes
    #StartAtBoot: True
#End Region
Sub Process_Globals
    'Private nid As Int = 1
    Private GPS As GPS
    Private Tracking As Boolean
    Private LastUpdateTime As Long
    Private lock As PhoneWakeState
    Private Distance As Double
    Private UserWasNotified As Boolean = False
End Sub
Sub Service_Create
    Service.AutomaticForegroundMode = Service.AUTOMATIC_FOREGROUND_NEVER 'we are handling it ourselves
    GPS.Initialize("gps")
    lock.PartialLock
End Sub
Sub Service_Start (StartingIntent As Intent)
    'Service.StartForeground(nid, CreateNotification("..."))
    Track
End Sub
Public Sub Track
    'Sleep(0)
    If Tracking Then Return
    If Starter.rp.Check(Starter.rp.PERMISSION_ACCESS_FINE_LOCATION) = False Then
        Log("No permission")
        Return
    End If
    GPS.Start(0, 0)
    Tracking = True
End Sub
Sub GPS_LocationChanged (Location1 As Location)
    If DateTime.Now > LastUpdateTime + 10 * DateTime.TicksPerSecond Then
        LastUpdateTime = DateTime.Now
        CheckDistance (Location1)
    End If
End Sub
Sub Service_Destroy
    If Tracking Then
        GPS.Stop
    End If
    Tracking = False
    lock.ReleasePartialLock
End Sub
Sub CheckDistance(Location1 As Location)
    Dim Location2 As Location
    Dim TrueCount As Byte = 0
    'Dim b As Beeper
    Public n As Notification = CreateNotification("Tap to Proceed.") 'This immediately calls the CreateNotification sub.
    'b.Initialize(300, 500) 'Initialize (Duration As Int, Frequency As Int)
    For Each TempContext As Context In Main.Contexts
        'Calculate distances to each context (location) that has a lat/lon.
        If TempContext.Latitude <> 0 Then 'Some contexts have no lat or lon.  Can't use them.
            'Find the distance from each context to the phone.
            Location2.Initialize2(TempContext.Latitude,TempContext.Longitude)
            Distance =  Location1.DistanceTo(Location2) * .00062137 'miles.
            Distance = Round2(Distance, 2)
            'ToastMessageShow (Main.Contexts(X,0)&": " & Distance & " miles.", True)
           
            'Check to see if the distance to the context is within the specifed distance to be considered "close".
            'Make a map of those that are close.
            If Distance < TempContext.Distance Then 'Context is Close.
                TempContext.Close = True
                'Log("Close Context = "&Main.Contexts(x,0))
                TrueCount = TrueCount + 1
                'ToastMessageShow("Close to " & Main.Contexts(x,0),True)
            Else 'Context is not close.
                TempContext.Close = False 'Clear close contexts from Context array.
                TempContext.Show = False 'Clear desired contexts from Context array.
            End If
        End If
        Main.Contexts.Set(Main.Contexts.IndexOf(TempContext),TempContext)
    Next
    If TrueCount > 0 Then 'Some of the contexts are close.
        Main.Close = True
        Log("MenuBuilt = "&Main.MenuBuilt)
        If Main.MenuBuilt = False Then
            CallSubDelayed(Main,"BuildMenuMap")
            Main.MenuBuilt = True
        End If
        If UserWasNotified = False Then
            'b.Beep  'Play a sound and show a message to let the user know.  A notification will also be raised in the Main activity.
            n.Notify(1)
            UserWasNotified = True
        End If
    Else
        Main.Close = False
        UserWasNotified = False
        n.Cancel(1)
    End If
    'Log("TrueCount = "&TrueCount)
    'Log("Close = "&Main.Close)
End Sub
Sub CreateNotification (Body As String) As Notification
    Log("CreateNotification sub started")
    Private notification As Notification
    notification.Initialize2(notification.IMPORTANCE_DEFAULT)
    notification.Icon = "icon"
    notification.AutoCancel = True 'This makes the notification go away when it is clicked on.
    notification.Sound = True
    notification.SetInfo("Contexts Nearby", Body, ShowMenuFlag)
    Log("CreateNotification sub done")
    Return notification
End SubAttachments
			
				Last edited: 
			
		
	
								
								
									
	
								
							
							 
				 
 
		 
						
					 
 
		