Что-то как следующее могло бы работать:
require 'socket'
require 'timeout'
def is_port_open?(ip, port)
begin
Timeout::timeout(1) do
begin
s = TCPSocket.new(ip, port)
s.close
return true
rescue Errno::ECONNREFUSED, Errno::EHOSTUNREACH
return false
end
end
rescue Timeout::Error
end
return false
end
Add android:windowSoftInputMode="stateAlwaysVisible" to your activity in the AndroidManifest.xml file:
<activity android:name=".MainActivity"
android:label="@string/app_name"
android:windowSoftInputMode="stateAlwaysVisible" />
In my test app this shows the keyboard on starting of the application although it isn't fixed there but can be dismissed by pressing the back button.
To make sure the keyboard is always visible you might have to create your own keyboard as part of the UI of your application. Here is a tutorial to show you how to do this with KeyboardView: http://www.fampennings.nl/maarten/android/09keyboard/index.htm