Guest User

android

a guest
Aug 29th, 2011
410
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.65 KB | None | 0 0
  1. package com.sencide;
  2.  
  3. //import java.util.ArrayList;
  4.  
  5. import java.net.SocketException;
  6.  
  7. import android.app.Activity;
  8. import android.app.AlertDialog;
  9. //import android.app.ProgressDialog;
  10. import android.content.DialogInterface;
  11. //import android.os.AsyncTask;
  12. import android.os.Bundle;
  13. import android.widget.TextView;
  14.  
  15. import org.ksoap2.SoapEnvelope;
  16. import org.ksoap2.serialization.SoapObject;
  17. import org.ksoap2.serialization.SoapPrimitive;
  18. import org.ksoap2.serialization.SoapSerializationEnvelope;
  19. //import org.ksoap2.transport.AndroidHttpTransport;
  20. import org.ksoap2.transport.HttpTransportSE;
  21.  
  22.  
  23. public class TestApp extends Activity {
  24.  
  25. private static final String SOAP_ACTION = "http://tempuri.org/getData";
  26.  
  27. private static final String METHOD_NAME = "getData";
  28.  
  29. private static final String NAMESPACE = "http://tempuri.org/";
  30. private static final String URL = "http://10.0.2.2/login2/Service1.asmx";
  31. TextView tv;
  32.  
  33. boolean[] bln1=null;
  34.  
  35. @Override
  36. public void onCreate(Bundle savedInstanceState) {
  37. super.onCreate(savedInstanceState);
  38. setContentView(R.layout.main);
  39. tv=(TextView)findViewById(R.id.text1);
  40.  
  41. String[] arr2= call();
  42. boolean[] bln=new boolean[arr2.length];
  43. for(int i=0;i<arr2.length;i++)
  44. {
  45.  
  46. bln[i]=false;
  47.  
  48. }
  49.  
  50. bln1 = new boolean[arr2.length];
  51.  
  52.  
  53. new AlertDialog.Builder(TestApp.this)
  54. .setIcon(R.drawable.alert_dialog_icon)
  55. .setTitle("Title")
  56. .setMultiChoiceItems(arr2,
  57. bln,
  58. new DialogInterface.OnMultiChoiceClickListener() {
  59. public void onClick(DialogInterface dialog, int whichButton,
  60. boolean isChecked) {
  61.  
  62.  
  63. if(isChecked){
  64. bln1[whichButton] = true;
  65. }
  66. else{
  67. bln1[whichButton] = false;
  68. }
  69. }
  70. })
  71. .setPositiveButton("Ok", new DialogInterface.OnClickListener() {
  72. public void onClick(DialogInterface dialog, int whichButton) {
  73.  
  74.  
  75. }
  76. })
  77. .setNegativeButton("Cancel", new DialogInterface.OnClickListener() {
  78. public void onClick(DialogInterface dialog, int whichButton) {
  79.  
  80.  
  81. }
  82. })
  83. .show();
  84.  
  85.  
  86. }
  87.  
  88.  
  89. public String[] call()
  90. {
  91. SoapPrimitive responsesData = null;
  92.  
  93. SoapObject request = new SoapObject(NAMESPACE, METHOD_NAME);
  94.  
  95. SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(
  96. SoapEnvelope.VER11);
  97. envelope.dotNet = true;
  98. envelope.setOutputSoapObject(request);
  99.  
  100. HttpTransportSE androidHttpTransport = new HttpTransportSE(URL);
  101.  
  102. androidHttpTransport.debug = true;
  103.  
  104. try {
  105.  
  106. androidHttpTransport.call(SOAP_ACTION, envelope);
  107.  
  108. responsesData = (SoapPrimitive) envelope.getResponse();
  109. System.out.println(" --- response ---- " + responsesData);
  110.  
  111. } catch (SocketException ex) {
  112. ex.printStackTrace();
  113. } catch (Exception e) {
  114. e.printStackTrace();
  115. }
  116. System.out.println( " ----" + responsesData );
  117.  
  118. String serviceResponse= responsesData .toString();
  119.  
  120.  
  121. String[] temp;
  122. String delimiter = "#";
  123. temp= serviceResponse.split(delimiter);
  124. System.out.println( " ---- length ---- " + temp.length);
  125.  
  126. return temp;
  127. }
  128.  
  129.  
  130. }
Advertisement
Add Comment
Please, Sign In to add comment