onyxbits / remotekeyboard

Android input method
http://www.onyxbits.de/remotekeyboard
Apache License 2.0
114 stars 25 forks source link

Exception on disabling #29

Open Starcommander opened 4 years ago

Starcommander commented 4 years ago

When remote-keyboard is activated, and telnet is connected, then switching keyboard fails. The exception occurs:

2187 12187 E Connection: android.os.NetworkOnMainThreadException 12-23 21:53:01.609 12187 12187 E Connection: at android.os.StrictMode$AndroidBlockGuardPolicy.onNetwork(StrictMode.java:1303) 12-23 21:53:01.609 12187 12187 E Connection: at java.net.SocketOutputStream.socketWrite(SocketOutputStream.java:111) ........... 2187 12187 E Connection: at net.wimpi.telnetd.TelnetD.stop(TelnetD.java:96) 12-23 21:53:01.609 12187 12187 E Connection: at de.onyxbits.remotekeyboard.RemoteKeyboardService.onDestroy(RemoteKeyboardService.java:124) 12-23 21:53:01.609 12187 12187 E Connection: at android.app.ActivityThread.handleStopService(ActivityThread.java:3396)

The notification does not disapear in this case, and it looks like remote-keyboard is still active. Disabling the TelnetConnection must be done in a thread. --> RemoteKeyboardService.java:124

Starcommander commented 4 years ago

My suggestion instead of telnetServer.stop();

Runnable rStop = new Runnable() { public void run() {telnetServer.stop();} };
new Thread(rStop).start();