2 Replies Latest reply on Jun 13, 2012 10:09 PM by rajesh_android

    wi-fi does not respond after couple of idle minutes

    rajesh_android

      Hello All,

       

      I have created a mobile app in Flex 4.6, Flash Builder 4.6.

       

      This is a fully internet dependent app and requires an active connection for all the time the app is running.

       

      But I have found that, when the app uses wi-fi connection, whatever the platform may be, either Android or iOS, the wi-fi automatically goes in sleep mode or does not respond with data or connection after about 5-6 minutes. this does not happen in case of cellular network.

       

      I have tried a few things but not proven effective.

       

      Thanks for reading.

        • 1. Re: wi-fi does not respond after couple of idle minutes
          drkstr_1 Level 4

          You should never assume a network connection will always be available. You need to implement logic to gracefully handle a network disconnect. It happens all the time, regardless of what kind of network/device you are on.

          • 2. Re: wi-fi does not respond after couple of idle minutes
            rajesh_android Level 1

            Hello,

            Thanks for reply,

             

            I have implemented some solutions for this but they do not prove to be effective every time. Also there is an API for checking the active connetions in devices which is not supported by apple devices.

             

            sample source codes

             

            public static function checkconnection():Boolean

            {

                                               var connectionFlag:Boolean = false;

                                               var interfaces:Vector.<NetworkInterface> = NetworkInfo.networkInfo.findInterfaces();

                     

                                          for(var i:int = 0; i < interfaces.length; i++)

                                          {

                                                    if(interfaces[i].name.toLowerCase() == "wifi" && interfaces[i].active)

                                                    {

                                                              connectionFlag=true;

                                                              break;

                                                    }

                               else if(interfaces[i].name.toLowerCase() == "mobile" && interfaces[i].active)

                                                    {

                                                              connectionFlag=true;

                                                              break;

                                                    }

             

                                          }

                                          return connectionFlag;

                                }

             

             

            AND,

             

            <s:WebService id="creobillservice" wsdl="{GlobalData.creo_webString}" showBusyCursor="true" fault="jsonservice_faultHandler()" result="creobillservice_resultHandler()">



            <s:operation name="accountmanager" result="accountmanagerResult_resultHandler(event)" fault="jsonservice_faultHandler()"/>

             

             

            public function jsonservice_faultHandler():void

                                          {

                                                    close_popup();

                                                    new nativetoast(this, "Connection failed. Check connection and try again.", 2000);

                                          }

             

             

            Please suggest if u have any better idea