久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

Android - 嘗試連接到本地服務器時出錯(Xampp)

Android - error while try connect to local server(Xampp)(Android - 嘗試連接到本地服務器時出錯(Xampp))
本文介紹了Android - 嘗試連接到本地服務器時出錯(Xampp)的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

問題描述

這是我的 logcat,第一行是我嘗試連接的 url,它是有效的 url

here's my logcat and the first line the url i try to connect with and it's valid url

她是我的代碼導致錯誤并拒絕連接

her is my code that cause the error and make the connection to refuse

public static String makeHttpRequest(URL url) throws IOException {
    String jsonResponse = "";
    Log.e(LOG_TAG, url.toString());

    // If the URL is null, then return early.
    if (url == null) {
        return jsonResponse;
    }

    HttpURLConnection urlConnection = null;
    InputStream inputStream = null;
    try {
        urlConnection = (HttpURLConnection) url.openConnection();

        urlConnection.setReadTimeout(10000 /* milliseconds */);
        urlConnection.setConnectTimeout(15000 /* milliseconds */);
        urlConnection.setRequestMethod("GET");
        urlConnection.connect();

        // If the request was successful (response code 200),
        // then read the input stream and parse the response.
        if (urlConnection.getResponseCode() == 200) {
            inputStream = urlConnection.getInputStream();
            jsonResponse = readFromStream(inputStream);
        } else {
            Log.e(LOG_TAG, "Error response code: " + urlConnection.getResponseCode());
        }
    } catch (IOException e) {
        Log.e(LOG_TAG, "Problem retrieving the Category JSON results.", e);
    } finally {
        if (urlConnection != null) {
            urlConnection.disconnect();
        }
        if (inputStream != null) {
            inputStream.close();
        }
    }
    return jsonResponse;
}

我已經知道如何使 Http 連接并且以前做過很多但這是第一次在本地服務器上

i already know how to make Http connect and done it a lot before but this the first time on local server

推薦答案

由于模擬器和筆記本的本地主機不同,您需要做以下操作:

Since local host for Emulator and Laptop is different, you need to do following:

  1. 使用筆記本電腦命令提示符中的 ipconfig 命令獲取 PC 的 IP 地址.
  2. 您應該在 URL 中使用 ipAddress,而不是使用 localhost.
  1. Get the IP address of your PC using: ipconfig command in your Laptop's command prompt.
  2. Instead of using localhost, you should use ipAddress in your URL.

所以您的地址將變為:http://<ip地址>/lotus/getstats.php?category=ATM

這篇關于Android - 嘗試連接到本地服務器時出錯(Xampp)的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!

【網站聲明】本站部分內容來源于互聯網,旨在幫助大家更快的解決問題,如果有圖片或者內容侵犯了您的權益,請聯系我們刪除處理,感謝您的支持!

相關文檔推薦

EditText: Disable Paste/Replace menu pop-up on Text Selection Handler click event(EditText:禁用文本選擇處理程序單擊事件上的粘貼/替換菜單彈出)
Multiline EditText with Done SoftInput Action Label on 2.3(2.3 上帶有完成 SoftInput 操作標簽的多行 EditText)
How to detect the swipe left or Right in Android?(如何在 Android 中檢測向左或向右滑動?)
Prevent dialog dismissal on screen rotation in Android(防止在Android中的屏幕旋轉對話框解除)
How do I handle ImeOptions#39; done button click?(如何處理 ImeOptions 的完成按鈕點擊?)
How do you set EditText to only accept numeric values in Android?(您如何將 EditText 設置為僅接受 Android 中的數值?)
主站蜘蛛池模板: 日韩欧美1区2区 | 羞羞视频免费在线 | 国产精品亚洲片在线播放 | 欧美精品一区二区三区蜜桃视频 | 中文字幕精品一区 | 欧美αv| 国产一区二区久久 | 夜夜操操操 | 欧美久久一区二区三区 | 亚洲欧美日韩激情 | 羞羞午夜 | 亚洲综合五月天婷婷 | 国产精品污www一区二区三区 | 精品一区二区三区91 | 91精品国产一二三 | 一区二区三区在线免费观看 | 蜜臀91视频 | 久久九精品 | 国产成人精品午夜 | 99久热在线精品视频观看 | 亚洲播放一区 | 一级毛片视频 | 日本视频在线播放 | 欧美日韩专区 | 欧美成人免费在线 | 超碰地址 | 亚洲精品欧美精品 | 国产一区二区欧美 | 中文字幕国产第一页 | 国产精品美女久久久久aⅴ国产馆 | 欧美一区二区在线视频 | 又黄又爽的网站 | 一级片视频免费观看 | 欧美极品少妇xxxxⅹ免费视频 | 欧美在线不卡 | 久久综合久久久 | 一区二区精品视频 | 99精品国产一区二区三区 | 中文字幕在线中文 | 91在线一区二区 | 日韩欧美在线视频 |