HttpHostConnectException: Connection refused Android

前端 未结 5 738
礼貌的吻别
礼貌的吻别 2021-02-09 14:53

I am trying to connect via HttpPost and send a username and password to a website and then receive a string from that website. I have tried various methods that have worked for

5条回答
  •  时光取名叫无心
    2021-02-09 15:32

    The problem is in wifi sleeping. Please use

    WifiManager wm = (WifiManager) getSystemService(Context.WIFI_SERVICE);
    wifiLock = wm.createWifiLock(WifiManager.WIFI_MODE_FULL , "MyWifiLock");
    wifiLock.acquire();
    

    and permission:

    uses-permission android:name="android.permission.WAKE_LOCK";
    

提交回复
热议问题