B4J Question Stop jtelegrambot

Yoldi

Member
Regards. I am doing a bot with jtelegrambot and if I go out and restart the application when initializing the bot it tells me that it is running on another thread. How can I stop it? Thank you.
 

Philip Chatzigeorgiadis

Active Member
Licensed User
Longtime User
B4X:
Sub mainform_Closed
    ExitApplication
End Sub

use this code on mainform
The jtelegrambot is a Non-UI application, so there is no mainform.

To terminate Non-UI applications, check these links:

https://www.b4x.com/android/forum/threads/killing-forgotten-java-processes.82584/
https://www.b4x.com/android/forum/threads/managing-hidden-jar-processes.110804/

Alternatively, you could kill the app through Task Manager (in Windows), but if you are running multiple jar processes, it would be hard to tell which process to kill.
 
Last edited:
Upvote 0

DonManfred

Expert
Licensed User
Longtime User
I stand corrected.
no. Sorry, my fault! IT is a nonui app... i just have the IDE open to see the LOG...

So, stopping the Bot must use the usually way to kill the java process.

Alternatively you can use a "Special" command to send to the bot. If the bot receives this command from a specific UID then the bot can be stopped by jtb.Stop and then calling exitapplication.
 
Upvote 0

Yoldi

Member
Regards.

I have an application with two buttons one to start the bot with jtb.startAsync and another button to stop the bot with jtb.stop.

stopping the bot and then starting it gives the following error java.lang.IllegalStateException: You cannot start the bot while it is not idle.

Is it possible to do this?

Thank you
 
Upvote 0

DonManfred

Expert
Licensed User
Longtime User
stop stopps the bot at the next timeout.

The Bot isn´t supposed to be stopped, started, stopped.

Create a App (NON UI). Start the bot and let it running.

There is no way to stop and start it again in the library behind.

Is it possible to do this?
No.
 
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…