While Scanning available wifi getting exception - java.lang.IllegalStateException: Reply already submitted

996

The WifiManager.startScan() usage is limited to 4 scans every 2 minutes. - All background apps combined are restricted to one scan every 30 minutes."

Please check that are you calling for WifiManager.startScan() more than four times in the duration of 2 minutes.

Reference link: https://developer.android.com/guide/topics/connectivity/wifi-scan#wifi-scan-throttling

Share:
996
Dhaval Kansara
Author by

Dhaval Kansara

iOS | Flutter Developer

Updated on December 18, 2022

Comments

  • Dhaval Kansara
    Dhaval Kansara over 1 year

    While I am requesting for the available wifi list in the network using wifi getting below exception.

    Exception:

    E/MethodChannel#plugins.ly.com/wifi(29023): Failed to handle method call
    E/MethodChannel#plugins.ly.com/wifi(29023): java.lang.IllegalStateException: Reply already submitted
    E/MethodChannel#plugins.ly.com/wifi(29023):     at io.flutter.embedding.engine.dart.DartMessenger$Reply.reply(DartMessenger.java:151)
    E/MethodChannel#plugins.ly.com/wifi(29023):     at io.flutter.plugin.common.MethodChannel$IncomingMethodCallHandler$1.error(MethodChannel.java:230)
    E/MethodChannel#plugins.ly.com/wifi(29023):     at com.ly.wifi.WifiDelegate.finishWithError(WifiDelegate.java:341)
    E/MethodChannel#plugins.ly.com/wifi(29023):     at com.ly.wifi.WifiDelegate.finishWithAlreadyActiveError(WifiDelegate.java:337)
    E/MethodChannel#plugins.ly.com/wifi(29023):     at com.ly.wifi.WifiDelegate.getWifiList(WifiDelegate.java:172)
    E/MethodChannel#plugins.ly.com/wifi(29023):     at com.ly.wifi.WifiPlugin.onMethodCall(WifiPlugin.java:58)
    E/MethodChannel#plugins.ly.com/wifi(29023):     at io.flutter.plugin.common.MethodChannel$IncomingMethodCallHandler.onMessage(MethodChannel.java:222)
    E/MethodChannel#plugins.ly.com/wifi(29023):     at io.flutter.embedding.engine.dart.DartMessenger.handleMessageFromDart(DartMessenger.java:96)
    E/MethodChannel#plugins.ly.com/wifi(29023):     at io.flutter.embedding.engine.FlutterJNI.handlePlatformMessage(FlutterJNI.java:656)
    E/MethodChannel#plugins.ly.com/wifi(29023):     at android.os.MessageQueue.nativePollOnce(Native Method)
    E/MethodChannel#plugins.ly.com/wifi(29023):     at android.os.MessageQueue.next(MessageQueue.java:336)
    E/MethodChannel#plugins.ly.com/wifi(29023):     at android.os.Looper.loop(Looper.java:174)
    E/MethodChannel#plugins.ly.com/wifi(29023):     at android.app.ActivityThread.main(ActivityThread.java:7356)
    E/MethodChannel#plugins.ly.com/wifi(29023):     at java.lang.reflect.Method.invoke(Native Method)
    E/MethodChannel#plugins.ly.com/wifi(29023):     at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:492)
    E/MethodChannel#plugins.ly.com/wifi(29023):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:930)
    I/flutter (29023): PlatformException(error, Reply already submitted, null)
    E/MethodChannel#plugins.ly.com/wifi(29023): Failed to handle method call
    E/MethodChannel#plugins.ly.com/wifi(29023): java.lang.IllegalStateException: Reply already submitted
    E/MethodChannel#plugins.ly.com/wifi(29023):     at io.flutter.embedding.engine.dart.DartMessenger$Reply.reply(DartMessenger.java:151)
    E/MethodChannel#plugins.ly.com/wifi(29023):     at io.flutter.plugin.common.MethodChannel$IncomingMethodCallHandler$1.error(MethodChannel.java:230)
    E/MethodChannel#plugins.ly.com/wifi(29023):     at com.ly.wifi.WifiDelegate.finishWithError(WifiDelegate.java:341)
    E/MethodChannel#plugins.ly.com/wifi(29023):     at com.ly.wifi.WifiDelegate.finishWithAlreadyActiveError(WifiDelegate.java:337)
    E/MethodChannel#plugins.ly.com/wifi(29023):     at com.ly.wifi.WifiDelegate.getWifiList(WifiDelegate.java:172)
    E/MethodChannel#plugins.ly.com/wifi(29023):     at com.ly.wifi.WifiPlugin.onMethodCall(WifiPlugin.java:58)
    E/MethodChannel#plugins.ly.com/wifi(29023):     at io.flutter.plugin.common.MethodChannel$IncomingMethodCallHandler.onMessage(MethodChannel.java:222)
    E/MethodChannel#plugins.ly.com/wifi(29023):     at io.flutter.embedding.engine.dart.DartMessenger.handleMessageFromDart(DartMessenger.java:96)
    E/MethodChannel#plugins.ly.com/wifi(29023):     at io.flutter.embedding.engine.FlutterJNI.handlePlatformMessage(FlutterJNI.java:656)
    E/MethodChannel#plugins.ly.com/wifi(29023):     at android.os.MessageQueue.nativePollOnce(Native Method)
    E/MethodChannel#plugins.ly.com/wifi(29023):     at android.os.MessageQueue.next(MessageQueue.java:336)
    E/MethodChannel#plugins.ly.com/wifi(29023):     at android.os.Looper.loop(Looper.java:174)
    E/MethodChannel#plugins.ly.com/wifi(29023):     at android.app.ActivityThread.main(ActivityThread.java:7356)
    E/MethodChannel#plugins.ly.com/wifi(29023):     at java.lang.reflect.Method.invoke(Native Method)
    E/MethodChannel#plugins.ly.com/wifi(29023):     at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:492)
    E/MethodChannel#plugins.ly.com/wifi(29023):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:930)
    I/flutter (29023): PlatformException(error, Reply already submitted, null)
    E/MethodChannel#plugins.ly.com/wifi(29023): Failed to handle method call
    E/MethodChannel#plugins.ly.com/wifi(29023): java.lang.IllegalStateException: Reply already submitted
    E/MethodChannel#plugins.ly.com/wifi(29023):     at io.flutter.embedding.engine.dart.DartMessenger$Reply.reply(DartMessenger.java:151)
    E/MethodChannel#plugins.ly.com/wifi(29023):     at io.flutter.plugin.common.MethodChannel$IncomingMethodCallHandler$1.error(MethodChannel.java:230)
    E/MethodChannel#plugins.ly.com/wifi(29023):     at com.ly.wifi.WifiDelegate.finishWithError(WifiDelegate.java:341)
    E/MethodChannel#plugins.ly.com/wifi(29023):     at com.ly.wifi.WifiDelegate.finishWithAlreadyActiveError(WifiDelegate.java:337)
    E/MethodChannel#plugins.ly.com/wifi(29023):     at com.ly.wifi.WifiDelegate.getWifiList(WifiDelegate.java:172)
    E/MethodChannel#plugins.ly.com/wifi(29023):     at com.ly.wifi.WifiPlugin.onMethodCall(WifiPlugin.java:58)
    E/MethodChannel#plugins.ly.com/wifi(29023):     at io.flutter.plugin.common.MethodChannel$IncomingMethodCallHandler.onMessage(MethodChannel.java:222)
    E/MethodChannel#plugins.ly.com/wifi(29023):     at io.flutter.embedding.engine.dart.DartMessenger.handleMessageFromDart(DartMessenger.java:96)
    E/MethodChannel#plugins.ly.com/wifi(29023):     at io.flutter.embedding.engine.FlutterJNI.handlePlatformMessage(FlutterJNI.java:656)
    E/MethodChannel#plugins.ly.com/wifi(29023):     at android.os.MessageQueue.nativePollOnce(Native Method)
    E/MethodChannel#plugins.ly.com/wifi(29023):     at android.os.MessageQueue.next(MessageQueue.java:336)
    E/MethodChannel#plugins.ly.com/wifi(29023):     at android.os.Looper.loop(Looper.java:174)
    E/MethodChannel#plugins.ly.com/wifi(29023):     at android.app.ActivityThread.main(ActivityThread.java:7356)
    E/MethodChannel#plugins.ly.com/wifi(29023):     at java.lang.reflect.Method.invoke(Native Method)
    E/MethodChannel#plugins.ly.com/wifi(29023):     at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:492)
    E/MethodChannel#plugins.ly.com/wifi(29023):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:930)
    I/flutter (29023): PlatformException(error, Reply already submitted, null)
    

    Code:

    Future<List<WifiResult>> getAvailableWifi() async {
    List<WifiResult> filteredList = [];
    bool match = true;
    
    return Wifi.list('');
    List<WifiResult> wifis =  await Wifi.list('');
    return wifis;
    }
    
  • Dhaval Kansara
    Dhaval Kansara about 4 years
    Thanks for the answer. It helps me and actually, I was requesting more than 4 times for startScan.