【问题标题】:Error in http connection!!android.os.NetworkOnMainThreadException [duplicate]http连接出错!android.os.NetworkOnMainThreadException [重复]
【发布时间】:2013-04-22 17:00:32
【问题描述】:

基本上,我在尝试请求 http 连接时遇到的唯一错误是,

Error in http connection !! android.os.NetworkOnMainThreadException

我正在尝试使用 android 模拟器连接到我的 Wamp 服务器中的数据库,这是我使用的代码的一部分,

   response = CustomHttpClient.executeHttpPost(
   "http://152.226.152.96:89/MPSIP/jsontestscript.php",
   postParameters);

我也尝试使用 localhost 而不是我的 IP,但我会得到完全相同的错误。

我想知道如何与我的 wampserver 建立 http 连接。我是错过了一步还是我做错了。

如果有帮助,我使用了来自的指南,

Link to example used here

【问题讨论】:

标签: java android json ip


【解决方案1】:

这可能是因为您在主/UI 线程上进行网络操作。了解AsyncTaskThread

阅读HERE

P.S:在 SO 上发布问题之前先进行一些谷歌搜索。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-11-10
    • 2013-09-06
    • 2014-01-08
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多