Android Question [SOLVED]Error with Service

Stulish

Active Member
Licensed User
Longtime User
Hi All i am using some old code that worked and i cant see why it crashes now?
All i want is the kiosk service to start the main activity at boot up, the panel PC this is to be installed on allows you to hide the navigation bar and status bar at the top and bottom of the screen and also stop the swipt up/down to view them so as long as the app is running it is KIOSK.

The old code for the service is below:

B4X:
#Region Module Attributes
    #StartAtBoot: True
#End Region

'Service module
Sub Process_Globals
    Dim Notification As Notification
    Dim Timer1 As Timer
    Dim limitNumberOfTicks As Int
End Sub
Sub Service_Create
    If Notification.IsInitialized = False Then
        Notification.Initialize
        Notification.Icon = "icon"
        Notification.SetInfo("Kiosk app", "Kiosk app", Main)
        Notification.Sound = False
        Notification.Vibrate = False
    End If
    Timer1.Initialize("Timer1", 10)
End Sub

Sub Service_Start (StartingIntent As Intent)
    Service.StartForeground(1, Notification)
    If IsPaused(Main) Then Timer1.Enabled = True
End Sub

Sub Service_Destroy
    Service.StopForeground(1)
    Timer1.Enabled = False
End Sub
Sub Timer1_Tick
    If IsPaused(Main) Then
        StartActivity(Main)
        limitNumberOfTicks = limitNumberOfTicks + 1
        If limitNumberOfTicks >= 10 Then Timer1.Enabled = False
    Else
        Timer1.Enabled = False
    End If
End Sub

The error i get at startup after i reboot the device is:


any ideas would be greatly received.

Thanks

Stu
 

Stulish

Active Member
Licensed User
Longtime User

Thanks aeric, That works great, such a small thing ??
 
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…