• After 15+ years, we've made a big change: Android Forums is now Early Bird Club. Learn more here.

Apps Web services and SoapObject ..about parsing xml??

ibo2011

Lurker
My Web service code ::
publicstatic DataSet CheckDistanceDB(string _Lat1, string _Long1)
{
return DatabaseAction.F_GENERIC_GET("SELECT Top(1) LT.Name as Name, L.LocationID as LocationID", "Location as L Inner Join LocationType as LT on L.LocationTypeID=LT.LocationTypeID", "WHERE (((cast(L.Latitude as decimal) - " + _Lat1 + ")*(cast(L.Latitude as decimal)- " + _Lat1 + ")) + ((cast(L.Longitude as decimal) - " + _Long1 + ")*(cast(L.Longitude as decimal) - " + _Long1 + ")))<=2500", "");
}
----------------------------------------------------------------
My Android Code ,,this code is working..:

public class main extends Activity {

String SOAP_ACTION =http://tempuri.org/CheckDistance;
String METHOD_NAME =CheckDistance;
String NAMESPACE =http://tempuri.org/;
String URL =http://webservice.navking.com/Service.asmx;
TextView tv;
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);

tv=(TextView)findViewById(R.id.text1);

try{
SoapObject request = new SoapObjec(NAMESPACE,METHOD_NAME);
request.addProperty(Lat1,41.06194785);
request.addProperty(Long1,28.97475539);
SoapSerializationEnvelope envelope =
new SoapSerializationEnvelope(SoapEnvelope.VER11);
envelope.dotNet =true;
AndroidHttpTransport httpTransport = new AndroidHttpTranspo(URL);
envelope.setOutputSoapObject(request);
httpTransport.debug=true;
httpTransport.call(SOAP_ACTION, envelope);
httpTransport.setXmlVersionTag("");
SoapObject result=(SoapObject)envelope.getResponse();
String Text = result.getProperty(1).toString();

tv.setText(Text);

} catch (Exception e) {
tv.setText(e.getMessage());
}

}
}

Get data web services..Information from Web services.
output:: anyType{NewDataSet=anyType{Table=anyType{Name=EDS; };Table=anyType{Name=EDS;};
Table=anyType{Name=Radar;};
Table=anyType{Name=Radar;};
Table=anyType{Name=Radar;};
Table=anyType{Name=Radar;};};}

I want to help me!!Soab object get data xml parsin !!!
How do i clear the xml tag here ?????
 
I I have written.LocationListner(GPS) and Google maps code..GPS and Map work together.I'm on the road and tries to gps...turning left or right.Map is rotate??How is this??????????? pleas help


package com.nit.android;


import com.google.android.maps.GeoPoint;
import com.google.android.maps.MapActivity;
import com.google.android.maps.MapView;
import com.google.android.maps.MyLocationOverlay;

import android.content.Context;
import android.location.Location;
import android.location.LocationListener;
import android.location.LocationManager;
import android.os.Bundle;
import android.widget.Toast;

public class MyLocationDemo extends MapActivity {


MapView mapView=null;
MyLocationOverlay whereAmI=null;
LocationListener locListener=null;
LocationManager locMgr=null;



@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);

mapView=(MapView) findViewById(R.id.geoMap);
mapView.setBuiltInZoomControls(true);
mapView.getController().setZoom(14);
whereAmI=new MyLocationOverlay(this, mapView);
mapView.getOverlays().add(whereAmI);
mapView.postInvalidate();


locMgr=(LocationManager)getSystemService(Context.LOCATION_SERVICE);
locListener=new LocationListener() {

public void onStatusChanged(String provider, int status, Bundle extras) {

}
public void onProviderEnabled(String provider) {
}

public void onProviderDisabled(String provider) {
}

public void onLocationChanged(Location location) {
showLocation(location);

}
};

}

@Override
protected boolean isRouteDisplayed() {
return false;
}

private void showLocation(Location location){
if(location !=null){
double lat=location.getLatitude();
double lng=location.getLongitude();

GeoPoint myLocation =new GeoPoint((int)(lat*1e6),(int)(lng*1e6));
Toast.makeText(getBaseContext(),"lat:"+lat+"and"+"long:"+lng, Toast.LENGTH_SHORT).show();
mapView.getController().animateTo(myLocation);


}
}
public void onResume(){
super.onResume();
Location lastLoc=locMgr.getLastKnownLocation(LocationManager.GPS_PROVIDER);
showLocation(lastLoc);
locMgr.requestLocationUpdates(LocationManager.GPS_PROVIDER, 1000, 1, locListener);
whereAmI.enableMyLocation();
whereAmI.runOnFirstFix(new Runnable() {

public void run() {
// TODO Auto-generated method stub
mapView.getController().setCenter(whereAmI.getMyLocation());
}
});
}
public void onPause(){
super.onPause();
locMgr.removeUpdates(locListener);
whereAmI.disableMyLocation();
}

}
---------------------------------------------
<?xml version="1.0" encoding="utf-8"?><!-- This file is /res/layout/main.xml -->
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent" android:layout_height="fill_parent">
<com.google.android.maps.MapView
android:id="@+id/geoMap"
android:clickable="true"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:apiKey="you key" />
</RelativeLayout>
----------------------------------
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.nit.android"
android:versionCode="1"
android:versionName="1.0">
<uses-sdk android:minSdkVersion="8" />

<application android:icon="@drawable/icon" android:label="@string/app_name">
<uses-library android:name="com.google.android.maps" />
<activity android:name=".MyLocationDemo"
android:label="@string/app_name">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>

</application>
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.READ_CONTACTS" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
<uses-permission android:name="android.permission.READ_PHONE_STATE" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
</manifest>
 
Back
Top Bottom