stealthcopter / AndroidNetworkTools

Set of useful android network tools
Apache License 2.0
1.39k stars 282 forks source link

App is blocking the UI and crashing in android 6.0 and below #51

Open nikhilgarg89 opened 5 years ago

nikhilgarg89 commented 5 years ago

App is blocking the UI and crashing in android 6.0 and below when i am doing subnet devices. this is reproducible in sample code.

nikhilgarg89 commented 5 years ago

@stealthcopter any workaround possible.. ??

nikhilgarg89 commented 5 years ago

@stealthcopter your help is appreciated

nikhilgarg89 commented 5 years ago

@stealthcopter your help is appreciated

lcabrales commented 5 years ago

@nikhilgarg89 Use the following method to run on the Ui thread inside onFinished or in onDeviceFound

@Override
public void onFinished(ArrayList<Device> devicesFound) {
    final List<Device> devices = devicesFound; //to be referenced inside the Handler

    //run on UI thread
    new Handler(Looper.getMainLooper()).post(new Runnable() {
        @Override
        public void run() {
            //todo manipulate UI
        }
    });
}
jerrychong25 commented 5 years ago

@lcabrales I have tried your solution by adding new Handler into my PortScan() function, however it still blocked my Progress Dialog and hang.

Is there any ways to prevent this blocking of Progress Dialog?

You may refer more details of my issues here: https://github.com/stealthcopter/AndroidNetworkTools/issues/58

Thanks.

jerrychong25 commented 5 years ago

@lcabrales @nikhilgarg89

Any clues on solving this issue?

Thanks.

stealthcopter commented 4 years ago

I've just tested the sample app on android 6.0 and I'm not having any UI blocking issues. What device are you using? Try lowering the thread count in case your device is using maximum CPU and causing an actual hang.

@jerrychong25 please post your full example with ProgressDialog and I'll run some tests on it to find out what's going on.

Thanks