更新时间:2023-02-26 13:40:22
您code可能是首先简化了,我建议你使用这个机器人库:
http://loopj.com/android-async-http/ ,让您尽样的HTTP请求。
Your code could be first of all simplified, i suggest you to use this android library: http://loopj.com/android-async-http/ which allows you to make every kind of HTTP requests.
在你下载了它,你应该很明显它导入到你的项目。
After you downloaded it you should obviously import it in your project.
code。与实施的Android异步HTTP客户端
Code with Android Asynchronous Http Client implemented
public class Final extends Activity {
AsyncHttpClient client = new AsyncHttpClient();
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_final);
Button btnSend = (Button)findViewById(R.id.BtnSend);
btnSend.setOnClickListener(new OnClickListener(){
public void onClick(View arg0){
TestReceiver();
}
});
void TestReceiver()
{
//ALERT MESSAGE
Toast.makeText(getBaseContext(),"Please wait, connecting to server.",Toast.LENGTH_LONG).show();
String Value="Kevin";
String url = "http://echogame24.comli.com/Receiver.php?action="+Value;
client.get(url, new AsyncHttpResponseHandler() {
@Override
public void onSuccess(String response) {
Toast.makeText(getBaseContext(),"Request made successfully.",Toast.LENGTH_LONG).show();
}
});
}
}
}