2024年4月18日发(作者:)

1. 在JDK的包中已经提供了访问HTTP协议的基本功能的类:

HttpURLConnection。

HttpURLConnection是Java的标准类,它继承自URLConnection,可用于向指定

网站发送GET请求、POST请求。

访问网络需要在中加入网络权限:

2. 访问网络需要创建新线程进行访问:

public void doTask(View v){

doPost

();

}

private void doPost() {

new Thread(new Runnable() {

@Override

public void run() {

Looper.

prepare

();

doPostByURL();

Looper.

loop

();

}

}).start();

}

public void doPostByURL()

{

try {

Spinner tGetNode = (Spinner) findViewById(.

spinnerGetSta

);

Spinner tPutNode = (Spinner)findViewById(.

spinnerPutSta

);

EditText tBoxCode = (EditText)findViewById(.

txtBoxCode

);

EditText tPartCode = (EditText)findViewById(.

txtPartCode

);