Hi Baris. We are not able to test your app for hours ('till the app crashes). It's abolutely necessary that you learn how to debug your apps. Of course we help with errors you can't fix on your own
For sure there is a log when it crashes. So please check it first (uncheck filtered logs) and see. Run it in debug or get the logs in Release by setting
Where you want but is good practise put this in first line module Main of course:
B4X:
#Region Project Attributes
#ApplicationLabel: B4A Example
#VersionCode: 1
#VersionName:
'SupportedOrientations possible values: unspecified, landscape or portrait.
#SupportedOrientations: unspecified
#CanInstallToExternalStorage: False
#End Region
#Region Activity Attributes
#FullScreen: False
#IncludeTitle: True
#End Region
#BridgeLogger: True
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 BtnSystemOnOff_CheckedChange(Checked As Boolean)
If TextFieldimei.Text.Length = 15 Then
If Starter.GPS1.GPSEnabled = True Then
If BtnSystemOnOff.Checked = True Then
BtnSystemOnOff.Color = Colors.Green
systemon = True
StartService(Starter)
Event = ""
Else
BtnSystemOnOff.Color = Colors.Red
systemon = False
StopService(Starter)
End If
Else
Msgbox(lblgpstextdisable, warningtitle1)
End If
Else
Msgbox(warning1, warningtitle1)
End If
End Sub
I added new service module named as "Starter2". I wrote the code below (StartServiceAt ....) into Starter2;
B4X:
#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)
StartServiceAt(Starter, DateTime.Now + 6 * DateTime.TicksPerSecond, True)
End Sub
Sub Service_Destroy
End Sub
To start the "Starter2" I wrote the code below into the Main;
B4X:
ub BtnSystemOnOff_CheckedChange(Checked As Boolean)
If TextFieldimei.Text.Length = 15 Then
If Starter.GPS1.GPSEnabled = True Then
If BtnSystemOnOff.Checked = True Then
BtnSystemOnOff.Color = Colors.Green
systemon = True
StartService(Starter2)
Event = ""
Else
BtnSystemOnOff.Color = Colors.Red
systemon = False
StopService(Starter2)
End If
Else
Msgbox(lblgpstextdisable, warningtitle1)
End If
Else
Msgbox(warning1, warningtitle1)
End If
End Sub