hey i am also new to android and have a same problem with me application here is my code please help
package projects.ksoap2sample;
import static android.provider.BaseColumns._ID;
import static projects.ksoap2sample.Constants.TABLE_NAME;
import static projects.ksoap2sample.Constants.BLOCK;
import static projects.ksoap2sample.Constants.DATE;
import static projects.ksoap2sample.Constants.DISTRICT;
import static projects.ksoap2sample.Constants.GRAM;
import static projects.ksoap2sample.Constants.LATITUDE;
import static projects.ksoap2sample.Constants.LONGITUDE;
import static projects.ksoap2sample.Constants.MOBILE;
import static projects.ksoap2sample.Constants.NAME;
import static projects.ksoap2sample.Constants.PRODUCT;
import static projects.ksoap2sample.Constants.STATUS;
import static projects.ksoap2sample.Constants.TIME;
import static projects.ksoap2sample.Constants.VILLAGE;
import projects.ksoap2sample.R;
import projects.ksoap2sample.Routemapping;
import projects.ksoap2sample.RouteMappingData;
import org.ksoap2.SoapEnvelope;
import org.ksoap2.serialization.PropertyInfo;
import org.ksoap2.serialization.SoapObject;
import org.ksoap2.serialization.SoapSerializationEnvelope;
import org.ksoap2.transport.AndroidHttpTransport;
import org.ksoap2.transport.HttpTransportSE;
import android.app.*;
import android.content.Intent;
import android.database.Cursor;
import android.database.sqlite.SQLiteDatabase;
import android.os.*;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.TextView;
import android.widget.Toast;
public class Web2 extends Activity implements OnClickListener {
/** Called when the activity is first created. */
private static final String SOAP_ACTION = "http://drishtee.in/WriteAndroideData";
private static final String METHOD_NAME = "WriteAndroideData";
private static final String NAMESPACE = "http://drishtee.in/";
private static final String URL = "http://quiver.in/mis/GPSManager.asmx/WriteGPSData?device_id=3";
private static final String LATITUDE = null;
private static final String LONGITUDE = null;
private static final String NAME = "sneha";
private static final String MOBILE = null;
private static final String PRODUCT = "coffee";
private static final String DISTRICT = "dr";
private static final String BLOCK = "blk";
private static final String GRAM = "gm";
private static final String VILLAGE = "vl";
private static final String DATE = null;
private static final String TIME = null;
private static final String STATUS = "running";
TextView tv;
private static String[] FROM = { _ID, LATITUDE, LONGITUDE, NAME, MOBILE, PRODUCT, DISTRICT, BLOCK, GRAM, VILLAGE, DATE, TIME, STATUS, };
private static String ORDER_BY = _ID + " ASC";
private RouteMappingData routeData;
private long id;
private double latitude;
private double longitude;
private String name;
private String mobile;
private String product;
private String district;
private String block;
private String gram;
private String village;
private String date;
private String time;
private String status;
private String a="false";
private int counter=1;
private SoapObject response;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
View homeButton1= findViewById(R.id.home_button1);
homeButton1.setOnClickListener(this);
tv=(TextView)findViewById(R.id.text1);
routeData=new RouteMappingData(this);
if(isOnline()==true)
{
checkStatus();
}
else
{
Toast.makeText(this, "Synchronization is not possible right now due to unavailability of Internet Connectivity", Toast.LENGTH_LONG).show();
}
//tv.setText(counter);
}
private boolean isOnline() {
// TODO Auto-generated method stub
return false;
}
public void onClick(View v) {
switch (v.getId()) {
case R.id.home_button1:
startActivity(new Intent(this, RouteMappingData.class));
call();
break;
}
}
public void checkStatus()
{
Cursor cursor=getEvents();
check(cursor);
}
private Cursor getEvents() {
routeData=new RouteMappingData(getBaseContext());
SQLiteDatabase db = routeData.getReadableDatabase();
String TABLE_NAME = null;
Cursor cursor = db.query(TABLE_NAME, FROM, null, null, null,
null, ORDER_BY);
startManagingCursor(cursor);
return cursor;
}
private void check(Cursor cursor)
{
while(cursor.moveToNext())
{
status=cursor.getString(12);
if(status.equals(a))
{
++counter;
id = cursor.getLong(0);
latitude = cursor.getDouble(1);
longitude = cursor.getDouble(2);
name=cursor.getString(3);
mobile=cursor.getString(4);
product=cursor.getString(5);
district=cursor.getString(6);
block=cursor.getString(7);
gram=cursor.getString(8);
village=cursor.getString(9);
date=cursor.getString(10);
time=cursor.getString(11);
Toast.makeText(Web2.this, name , Toast.LENGTH_SHORT).show();
}
else
Toast.makeText(this, "Synchronization not done", Toast.LENGTH_LONG).show();
}
}
private void call() {
//TODO Auto-generated method stub
try {
Category C=new Category();
C.device_id=1;
SoapObject request = new SoapObject(NAMESPACE, METHOD_NAME);
PropertyInfo pidev = new PropertyInfo();
pidev.setName("C");
pidev.setValue(C);
pidev.setType(String.class);
request.addProperty(pidev);
PropertyInfo pi = new PropertyInfo();
pi.setName("C");
pi.setValue(id);
pi.setType(long.class);
request.addProperty(pi);
PropertyInfo pi1 = new PropertyInfo();
pi1.setName("C");
pi1.setValue(2);
pi1.setType(double.class);
request.addProperty(pi1);
PropertyInfo pi2=new PropertyInfo();
pi2.setName("C");
pi2.setValue(3);
pi2.setType(double.class);
request.addProperty(pi2);
PropertyInfo pi3=new PropertyInfo();
pi3.setName("C");
pi3.setValue(name);
pi3.setType(String.class);
request.addProperty(pi3);
PropertyInfo pi4=new PropertyInfo();
pi4.setName("C");
pi4.setValue(village);
pi4.setType(String.class);
request.addProperty(pi4);
PropertyInfo pi5=new PropertyInfo();
pi5.setName("C");
pi5.setValue(mobile);
pi5.setType(String.class);
request.addProperty(pi5);
PropertyInfo pi6=new PropertyInfo();
pi6.setName("C");
pi6.setValue(gram);
pi6.setType(String.class);
request.addProperty(pi6);
PropertyInfo pi7=new PropertyInfo();
pi7.setName("C");
pi7.setValue(date);
pi7.setType(String.class);
request.addProperty(pi7);
//request.addProperty("prop1", "myprop");
SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);
envelope.dotNet=true;
envelope.setOutputSoapObject(request);
envelope.addMapping(NAMESPACE, "Category",new Category().getClass());
AndroidHttpTransport androidHttpTransport = new AndroidHttpTransport(URL);
androidHttpTransport.call(SOAP_ACTION, envelope);
SoapObject resultsRequestSOAP = (SoapObject) envelope.bodyIn;
Object result = (Object)envelope.getResponse();
String[] results = (String[]) result;
C.device_id = Integer.parseInt(response.getProperty(0).toString());
C.Name = response.getProperty(1).toString();
C.latitude=response.getProperty(2).toString();
C.longitude=response.getProperty(3).toString();
C.Mobile = (String) response.getProperty(2).toString();
tv.setText( ""+results[0]);
tv.setText("Device_id: " +C.device_id + " Name: " + C.Name + " longitude " + C.longitude);
}
catch (Exception e) {
tv.setText("Error occured");
}
String result1=counter+" Data have been Synchronized Successfully.";
tv.setText(result1);
}
}
thanks in advance..