Closed jerrychong25 closed 4 years ago
@SemenovAlexander
Any updates on this?
Thanks.
@jerrychong25 @SemenovAlexander Hi Both,
I've used the following code on android 6.0 and 9.0 and do not get UI blocking. I'll run some tests on < 6.0 and see what I get. Do you still get the blocking if you set the thread count to a low number? might be worth testing with 1.
// Find Port Number Asynchronously
PortScan.onAddress("192.168.0.50").setTimeOutMillis(500).setPortsAll().setMethodTCP().doScan(new PortScan.PortListener() {
@Override
public void onResult(int portNo, boolean open) {
Log.e("TEST","Result: "+portNo+" "+open);
}
@Override
public void onFinished(ArrayList<Integer> openPorts) {
Log.e("TEST","Result: "+openPorts.size());
}
});
@jerrychong25 @SemenovAlexander Hi Both,
I've used the following code on android 6.0 and 9.0 and do not get UI blocking. I'll run some tests on < 6.0 and see what I get. Do you still get the blocking if you set the thread count to a low number? might be worth testing with 1.
// Find Port Number Asynchronously PortScan.onAddress("192.168.0.50").setTimeOutMillis(500).setPortsAll().setMethodTCP().doScan(new PortScan.PortListener() { @Override public void onResult(int portNo, boolean open) { Log.e("TEST","Result: "+portNo+" "+open); } @Override public void onFinished(ArrayList<Integer> openPorts) { Log.e("TEST","Result: "+openPorts.size()); } });
No issue on low number.
But in my application use case, I need to set setPortsAll() function so is there any other workaround for this?
Related to this issue...
In my case, my Activity
calls a method called scan_subnet()
, which does a subnet scan. When calling scan_subnet()
from onCreate()
, the Activity
hasn't finished rendering its UI yet, and so freezes/locks up/blocks until the scan is complete.
I was able to fix this by hooking into the onWindowFocusChanged
event instead of onCreate
or onResume
or even onAttachedToWindow
, each of which blocks the UI before the Activity
is fully rendered.
//kotlin
override fun onWindowFocusChanged(hasFocus: Boolean) {
super.onWindowFocusChanged(hasFocus)
if(hasFocus) {
scan_subnet()
}
}
This feels a bit hacky, but works for my needs.
I would like this library to handle the UI blocking issues more elegantly, without having to manually deal with threading concerns.
No longer using AndroidNetworkTools nowadays. Will close this issue.
Thanks all!
Hi all,
I have implemented PortScan() function successfully.
However, it will block my Progress Dialog when running PortScan() function, whereby my Progress Dialog is called before PortScan() function.
The Progress Dialog is stopped and hang half way until the PortScan() is executed completely.
Is there any way to prevent blocking of my Progress Dialog when running PortScan() function?
Thanks.
My Source Code: