I am trying to find my way around ssh command execution using Ribber's jkSSH2 library version 1.10. The same NetworkOnMainThreadException (newer Android sdk levels will not permit networking in the main ui thread) is already fixed for the HttpUtils2 library. Is there any way for me to use jkSSH2 with API level > 8?
Hello, I have the same problem. The error get when you run the command on the server. If I execute ssh2.isconnected, the answer is false, but no errors when trying to connect. With Android 4.0 I have the problem with 2.3 no. you have discovered something?
Just to ping this thread. Is there any update to the SSH threading issue? I'm trying to make a small app which has multiple buttons each calling a different command on the PC via SSH.
Dim p As Phone
If p.SdkVersion >= 9 Then
Dim r As Reflector
r.Target = r.CreateObject("android.os.StrictMode$ThreadPolicy$Builder")
r.Target = r.RunMethod("permitAll")
r.Target = r.RunMethod("build")
r.RunStaticMethod("android.os.StrictMode", "setThreadPolicy", _
Array As Object(r.Target), Array As String("android.os.StrictMode$ThreadPolicy"))
End If
Dim p As Phone
If p.SdkVersion >= 9 Then
Dim r As Reflector
r.Target = r.CreateObject("android.os.StrictMode$ThreadPolicy$Builder")
r.Target = r.RunMethod("permitAll")
r.Target = r.RunMethod("build")
r.RunStaticMethod("android.os.StrictMode", "setThreadPolicy", _
Array As Object(r.Target), Array As String("android.os.StrictMode$ThreadPolicy"))
End If
Android 4+ doesn't allow applications to make network calls on the main thread. There is a good reason for this restriction as such calls cause the UI to freeze and after 5 second Android will show the "Application not responding" dialog. Proper libraries take care of handling network calls...
www.b4x.com
It will prevent the error and crash by allowing network on main.