Pastebin launched a little side project called VERYVIRAL.com, check it out ;-) Want more features on Pastebin? Sign Up, it's FREE!
Guest

android code

By: a guest on Aug 22nd, 2011  |  syntax: None  |  size: 3.57 KB  |  views: 204  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. package com.demo;
  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.                        
  42.         String[] arr2= call();
  43.         boolean[] bln = {false, false, false};
  44.        
  45.        bln1 = new boolean[arr2.length];
  46.        
  47.  
  48.         new AlertDialog.Builder(TestApp.this)
  49.         .setIcon(R.drawable.alert_dialog_icon)
  50.         .setTitle("Title")
  51.         .setMultiChoiceItems(arr2,
  52.                 bln,
  53.                 new DialogInterface.OnMultiChoiceClickListener() {
  54.                     public void onClick(DialogInterface dialog, int whichButton,
  55.                             boolean isChecked) {
  56.  
  57.                        
  58.                         if(isChecked){
  59.                                 bln1[whichButton] = true;
  60.                         }
  61.                         else{
  62.                                 bln1[whichButton] = false;
  63.                         }
  64.                     }
  65.                 })
  66.         .setPositiveButton("Ok", new DialogInterface.OnClickListener() {
  67.             public void onClick(DialogInterface dialog, int whichButton) {
  68.  
  69.                
  70.             }
  71.         })
  72.         .setNegativeButton("Cancel", new DialogInterface.OnClickListener() {
  73.             public void onClick(DialogInterface dialog, int whichButton) {
  74.  
  75.                
  76.             }
  77.         })
  78.        .show();
  79.        
  80.        
  81.     }
  82.    
  83.          
  84.     public String[] call()
  85.     {
  86.         SoapPrimitive responsesData = null;
  87.  
  88.         SoapObject request = new SoapObject(NAMESPACE, METHOD_NAME);
  89.  
  90.         SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(
  91.         SoapEnvelope.VER11);
  92.         envelope.dotNet = true;
  93.         envelope.setOutputSoapObject(request);
  94.        
  95.         HttpTransportSE androidHttpTransport = new HttpTransportSE(URL);
  96.        
  97.         androidHttpTransport.debug = true;
  98.  
  99.         try {
  100.                
  101.         androidHttpTransport.call(SOAP_ACTION, envelope);
  102.        
  103.         responsesData = (SoapPrimitive) envelope.getResponse();
  104.         System.out.println(" --- response ---- " + responsesData);
  105.  
  106.         } catch (SocketException ex) {
  107.         ex.printStackTrace();
  108.         } catch (Exception e) {
  109.         e.printStackTrace();
  110.         }
  111.         System.out.println( " ----" + responsesData );
  112.        
  113.         String serviceResponse= responsesData .toString();
  114.        
  115.        
  116.         String[] temp;
  117.         String delimiter = "#";
  118.         temp= serviceResponse.split(delimiter);
  119.         System.out.println( " ---- length ---- " + temp.length);
  120.        
  121.         return temp;
  122.         }
  123.    
  124.          
  125. }