Service start and stop

sktanmoy

Active Member
Licensed User
Longtime User
Check the code first

B4X:
Sub Start_Click
   Try
   StartService(SMSy)
   Msgbox("Service Started", "")
   Catch
   Msgbox("Unable to start", "")
   End Try
   
End Sub
Sub Stop_Click
   Try
   StopService(SMSy)
   Msgbox("Service Stopped", "")
   Catch
   Msgbox("Unable to start", "")
   End Try
End Sub

Success message is being shown when I'm clicking on Stop button. Nothing for Start, neither success not failure.

But service is being run and doing it's work well.

Need your help.:sign0163:
 

mc73

Well-Known Member
Licensed User
Longtime User
Please log("start is clicked") at the beginning of your start_click sub. Do you receive a log?
 
Upvote 0

sktanmoy

Active Member
Licensed User
Longtime User
Nop

Nop, nothing was logged. I've attached a project. That was working for me but no response in start button click.
 
Last edited:
Upvote 0

mc73

Well-Known Member
Licensed User
Longtime User
Please, remove the startService from your Service_Start sub in your module. This is causing an infinite start&destroy of your service, and is the cause you don't receive a log. In general, you should always check (at least) the filtered logs. If you did that, you would see this bad loop I've just described.
 
Upvote 0

sktanmoy

Active Member
Licensed User
Longtime User
Please, remove the startService from your Service_Start sub in your module. This is causing an infinite start&destroy of your service, and is the cause you don't receive a log. In general, you should always check (at least) the filtered logs. If you did that, you would see this bad loop I've just described.

Thanks for the answer, and I noticed the loop also.

But as I'm fully new here, have no idea on that, just followed a video from youtube.

Thanks again for the solution.
 
Last edited:
Upvote 0
Top