Advertisement
Guest User

Untitled

a guest
Jul 29th, 2014
235
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.08 KB | None | 0 0
  1. package com.dicorp.completesmspackage;
  2.  
  3. import java.util.ArrayList;
  4. import java.util.List;
  5.  
  6. import org.ksoap2.SoapEnvelope;
  7. import org.ksoap2.serialization.SoapObject;
  8. import org.ksoap2.serialization.SoapSerializationEnvelope;
  9. import org.ksoap2.transport.HttpTransportSE;
  10.  
  11.  
  12.  
  13.  
  14.  
  15.  
  16.  
  17. import android.app.Activity;
  18. import android.content.Intent;
  19. import android.os.Bundle;
  20. import android.os.Handler;
  21. import android.os.Message;
  22. import android.view.View;
  23. import android.widget.AdapterView;
  24. import android.widget.AdapterView.OnItemClickListener;
  25. import android.widget.ArrayAdapter;
  26. import android.widget.ListView;
  27.  
  28. public class Specialityofdocs extends Activity{
  29.  
  30.  
  31. ListView listview;
  32.  
  33. public static String SOAP_ACTION = "http://tempuri.org/SpecialityList";
  34.  
  35. public static String NAMESPACE = "http://tempuri.org/";
  36.  
  37. public static String METHOD_NAME = "SpecialityList";
  38.  
  39. private static String URL = "http://115.119.182.114/FortisWS/FortisWebService.asmx";
  40.  
  41. ArrayList<String> specialityid=new ArrayList<String>();
  42. ArrayList<String> specialityname=new ArrayList<String>();
  43.  
  44.  
  45. @Override
  46. protected void onCreate(Bundle savedInstanceState) {
  47. // TODO Auto-generated method stub
  48. super.onCreate(savedInstanceState);
  49. setContentView(R.layout.specialityofdocs);
  50.  
  51. listview=(ListView) findViewById(R.id.listviewsdocs);
  52.  
  53. Thread networktThread=new Thread(){
  54.  
  55.  
  56.  
  57. @Override
  58. public void run() {
  59. // TODO Auto-generated method stub
  60. try
  61. {
  62. SoapObject request = new SoapObject(NAMESPACE, METHOD_NAME);
  63.  
  64. SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);
  65. envelope.dotNet=true;
  66. envelope.setOutputSoapObject(request);
  67.  
  68.  
  69. HttpTransportSE ht = new HttpTransportSE(URL);
  70. request.addProperty("TimeStamp", "");
  71. ht.call(SOAP_ACTION, envelope);
  72.  
  73.  
  74. final SoapObject result = (SoapObject) envelope.getResponse();
  75.  
  76. runOnUiThread(new Runnable() {
  77.  
  78. @Override
  79. public void run() {
  80. // TODO Auto-generated method stub
  81.  
  82. int count=result.getPropertyCount();
  83. System.out.println("in count "+count);
  84.  
  85. SoapObject result1=(SoapObject) result.getProperty(2);
  86. int count1=result1.getPropertyCount();
  87.  
  88. for (int i = 0; i<= count1-1; i++)
  89. {
  90. SoapObject result2=(SoapObject) result1.getProperty(i);
  91. specialityid.add(result2.getProperty(0).toString());
  92. specialityname.add(result2.getProperty(1).toString());
  93.  
  94.  
  95. System.out.println("id for hospital" +result2.getProperty(0).toString());
  96.  
  97.  
  98.  
  99. System.out.println("speciality of hospital"+result2.getProperty(1).toString());
  100.  
  101.  
  102.  
  103. }
  104.  
  105.  
  106.  
  107.  
  108. }
  109. });
  110.  
  111.  
  112. }catch(Exception e)
  113. {
  114. e.printStackTrace();
  115. }
  116. handle.sendEmptyMessage(0);
  117. }
  118.  
  119. };
  120.  
  121. listview.setOnItemClickListener(new OnItemClickListener() {
  122.  
  123. @Override
  124. public void onItemClick(AdapterView<?> arg0, View arg1, int arg2,
  125. long arg3) {
  126. // TODO Auto-generated method stub
  127. //Intent intent=new Intent(Specialityofdocs.this,BackupRestoreActivity.class);
  128. //intent.putExtra("SEND_SPECIALITY", specialityname.get(arg2).toString());
  129. System.out.println("hello j"+specialityname.get(arg2).toString());
  130. //startActivity(intent);
  131.  
  132. }
  133. });
  134.  
  135. networktThread.start();
  136. }
  137.  
  138. private Handler handle=new Handler(){
  139.  
  140. @Override
  141. public void handleMessage(Message msg) {
  142. // TODO Auto-generated method stub
  143. super.handleMessage(msg);
  144.  
  145. ArrayAdapter<String> adapts;
  146. adapts=new ArrayAdapter<String>(getBaseContext(), android.R.layout.simple_list_item_1, specialityname);
  147. listview.setAdapter(adapts);
  148.  
  149.  
  150. }
  151.  
  152. };
  153.  
  154.  
  155. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement