WEB开发网
开发学院手机开发Android 开发 Android HttpConnect 阅读

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 j

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);

1 2 3 4 5 6  下一页

Tags:Android HttpConnect

编辑录入:爽爽 [复制链接] [打 印]
赞助商链接