Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/198.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
android eclipse中的HTTP连接错误_Android_Eclipse - Fatal编程技术网

android eclipse中的HTTP连接错误

android eclipse中的HTTP连接错误,android,eclipse,Android,Eclipse,我正在尝试使用以下代码将他在应用程序中输入的用户电话号码发送到我的本地主机数据库: Submit.setOnClickListener(new View.OnClickListener() { InputStream is=null; @Override public void onClick(View arg0) { //Storing the values inside the Edit

我正在尝试使用以下代码将他在应用程序中输入的用户电话号码发送到我的本地主机数据库:

Submit.setOnClickListener(new View.OnClickListener() {
            InputStream is=null;

            @Override
            public void onClick(View arg0) {
                //Storing the values inside the EditText inside the String Variable
                String PhoneNumber=""+etPhoneNumber.getText().toString();

                //Setting Up the nameValuePairs
                List<NameValuePair> nameValuePairs =new ArrayList<NameValuePair>(1);

                //Adding the string variable inside the NameValuePair
                nameValuePairs.add(new BasicNameValuePair("PhoneNumber", PhoneNumber));

                //Setting Up the Connection inside the try catch block
                try {
                    //Setting up the default http client
                    HttpClient httpClient = new DefaultHttpClient();
                    HttpPost httpPost = new HttpPost("http://192.168.15.210/index.php");

                    //passing the name pair variables inside the httpPost
                    httpPost.setEntity(new UrlEncodedFormEntity(nameValuePairs));

                    //Getting the response
                    HttpResponse response =httpClient.execute(httpPost);
                    Log.i("Tag","nameValuePairs");

                    //setting up the http response
                    HttpEntity entity =response.getEntity();

                    //Setting up the content inside an input stream reader
                    //Lets define the input stream reader
                    is = entity.getContent();

                    //Displaying the Toast msg if the data is entered successfully
                    String msg="Data is entered successfully";
                    Toast.makeText(getApplicationContext(), msg, Toast.LENGTH_LONG).show();
                } catch(ClientProtocolException e) {
                    Log.e("ClientProtocol","Log_tag");
                    e.printStackTrace();
                } catch(IOException e) {
                    Log.e("Log_tag","IOException");
                    e.printStackTrace();
                }
            }
        });
    }
}

不要在
主线程上运行网络操作。并确保在清单文件中具有internet权限我已在主活动中添加了以下行:'//StricTPolicy StrictMode.ThreadPolicy policy=new StrictMode.ThreadPolicy.Builder().permitAll().build();StrictMode.setThreadPolicy(策略);setContentView(R.layout.activity_main);'所以它不会限制主线程中的网络连接,仍然不起作用
07-08 03:33:14.138: W/System.err(23711): org.apache.http.conn.HttpHostConnectException: Connection to http://192.168.15.210 refused
07-08 03:33:14.170: W/System.err(23711):    at org.apache.http.impl.conn.DefaultClientConnectionOperator.openConnection(DefaultClientConnectionOperator.java:183)
07-08 03:33:14.170: W/System.err(23711):    at org.apache.http.impl.conn.AbstractPoolEntry.open(AbstractPoolEntry.java:164)
07-08 03:33:14.170: W/System.err(23711):    at org.apache.http.impl.conn.AbstractPooledConnAdapter.open(AbstractPooledConnAdapter.java:119)
07-08 03:33:14.170: W/System.err(23711):    at org.apache.http.impl.client.DefaultRequestDirector.execute(DefaultRequestDirector.java:365)
07-08 03:33:14.170: W/System.err(23711):    at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:555)
07-08 03:33:14.170: W/System.err(23711):    at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:487)
07-08 03:33:14.170: W/System.err(23711):    at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:465)
07-08 03:33:14.172: W/System.err(23711):    at org.apache.http.impl.conn.DefaultClientConnectionOperator.openConnection(DefaultClientConnectionOperator.java:181)
07-08 03:33:14.175: W/System.err(23711):    at org.apache.http.conn.scheme.PlainSocketFactory.connectSocket(PlainSocketFactory.java:119)
07-08 03:33:14.175: W/System.err(23711):    at org.apache.http.impl.conn.DefaultClientConnectionOperator.openConnection(DefaultClientConnectionOperator.java:144)