Android HttpConnect
2010-10-19 20:17:34 来源:WEB开发网view plaincopy to clipboardprint?
1. package my.android.hc;
2.
3. import java.util.ArrayList;
4. import java.util.List;
5. import java.util.regex.Matcher;
6. import java.util.regex.Pattern;
7.
8. import org.apache.http.HttpResponse;
9. import org.apache.http.NameValuePair;
10. import org.apache.http.client.entity.UrlEncodedFormEntity;
11. import org.apache.http.client.methods.HttpGet;
12. import org.apache.http.client.methods.HttpPost;
13. import org.apache.http.impl.client.DefaultHttpClient;
14. import org.apache.http.message.BasicNameValuePair;
15. import org.apache.http.protocol.HTTP;
16. import org.apache.http.util.EntityUtils;
17.
18. import android.app.Activity;
19. import android.os.Bundle;
20. import android.view.View;
21. import android.widget.Button;
22. import android.widget.TextView;
23.
24. public class HttpConnect extends Activity {
25. private Button mb1,mb2;
26. private TextView mtv1;
27.
28. /** Called when the activity is first created. */
29. @Override
30. public void onCreate(Bundle savedInstanceState) {
31. super.onCreate(savedInstanceState);
32. setContentView(R.layout.main);
33.
34. mb1 = (Button) findViewById(R.id.b1_id);
35. mb2 = (Button) findViewById(R.id.b2_id);
36. mtv1 = (TextView) findViewById(R.id.tv1_id);
37.
38. mb1.setOnClickListener(new Button.OnClickListener() {
39. public void onClick(View v) {
40. // TODO Auto-generated method stub
41. String uriAPI = "http://www.dubblogs.cc:8751/android/test/api/post/index.php";
42. HttpPost httpRequest = new HttpPost(uriAPI);
Tags:Android HttpConnect
编辑录入:爽爽 [复制链接] [打 印]- ››Android 当修改一些代码时,使用什么编译命令可以最...
- ››Android 如何添加一个apk使模拟器和真机都编译进去...
- ››Android 修改Camera拍照的默认保存路径
- ››Android 如何修改默认输入法
- ››android开发中finish()和System.exit(0)的区别
- ››Android手势识别简单封装类
- ››android中查看项目数字证书的两种方法
- ››Android中获取IMEI码的办法
- ››android 相机报错 setParameters failed
- ››Android重启运用程序的代码
- ››Android为ListView的Item设置不同的布局
- ››android bitmap与base64字符串的互相转换
更多精彩
赞助商链接