AndroidNetworkTools icon indicating copy to clipboard operation
AndroidNetworkTools copied to clipboard

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

Open nikhilgarg89 opened this issue 7 years ago • 7 comments

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 avatar Oct 09 '18 06:10 nikhilgarg89

@stealthcopter any workaround possible.. ??

nikhilgarg89 avatar Oct 14 '18 06:10 nikhilgarg89

@stealthcopter your help is appreciated

nikhilgarg89 avatar Oct 18 '18 11:10 nikhilgarg89

@stealthcopter your help is appreciated

nikhilgarg89 avatar Nov 03 '18 05:11 nikhilgarg89

@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
        }
    });
}

lcabrales avatar Apr 16 '19 16:04 lcabrales

@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 avatar Sep 09 '19 06:09 jerrychong25

@lcabrales @nikhilgarg89

Any clues on solving this issue?

Thanks.

jerrychong25 avatar Sep 21 '19 11:09 jerrychong25

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

stealthcopter avatar Nov 03 '19 11:11 stealthcopter