Why I am getting the HttpHostConnectException

后端 未结 2 1491
情歌与酒
情歌与酒 2020-12-30 11:59

I am using the following code in android virtual Machine

 try{
       HttpClient httpclient = new DefaultHttpClient();
       HttpPost httppost = new HttpPos         


        
相关标签:
2条回答
  • 2020-12-30 12:23

    Did you declare the Internet permission in the AndroidManifest.xml?

    You need to put the following into the AndroidManifest.xml

    <manifest> 
      ...
      <uses-permission android:name="android.permission.INTERNET"/>
    </manifest>
    
    0 讨论(0)
  • 2020-12-30 12:31

    internet permission to your application by adding this under manifest tag in your AndroidManifest.xml

    <uses-permission android:name="android.permission.INTERNET" />
    

    otherwise Android will block internet traffic from your app

    0 讨论(0)
提交回复
热议问题