seetharam1000
Newbie
hi
i would like to store the coordinates in data base, but these line will store any other value (like 1, 2,3, etc) not the coordinates value. how to make the coordinates to double, the bold line shown below.
i would like to store the coordinates in data base, but these line will store any other value (like 1, 2,3, etc) not the coordinates value. how to make the coordinates to double, the bold line shown below.
Code:
package com.example.login2;
import java.util.ArrayList;
import org.apache.http.NameValuePair;
import org.apache.http.message.BasicNameValuePair;
import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.location.Criteria;
import android.location.Location;
import android.location.LocationListener;
import android.location.LocationManager;
import android.net.wifi.WifiManager;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.TextView;
import android.widget.Toast;
public class second extends Activity {
/** Called when the activity is first created. */
TextView L1, L2, output, output1;
Button B1;
Button button2;
LocationManager locationManager;
String provider, txt;
LocationListener locListener;
WifiManager wifi;
double lat, longi;
public static String output2, name;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main2);
B1 = (Button) findViewById(R.id.button1);
L2 = (TextView) findViewById(R.id.lat1);
L1 = (TextView) findViewById(R.id.long1);
output = (TextView) findViewById(R.id.output);
output1 = (TextView) findViewById(R.id.output1);
Intent i = getIntent();
// Receiving the Data
name = i.getStringExtra("name");
output1.setText(name);
locationManager = (LocationManager) getSystemService(Context.LOCATION_SERVICE);
lat = L1.getTextScaleX();
longi = L2.getTextScaleX();
ArrayList<NameValuePair> postParameters = new ArrayList<NameValuePair>();
postParameters.add(new BasicNameValuePair("UserName", output1.getText().toString()));
postParameters.add(new BasicNameValuePair([B]"latitude", Double
.toString(lat)));[/B]
postParameters.add(new BasicNameValuePair([B]"longitude", Double
.toString(longi)));[/B]
// String valid = "1";
String response = null;
try {
response = CustomHttpClient
.executeHttpPost(
"http://testing.itotally.co.uk/gpslocationstorage.php",
postParameters);
String res = response.toString();
output.setText(res);
Criteria criteria = new Criteria();
locationManager = (LocationManager) getSystemService(Context.LOCATION_SERVICE);
Location location = locationManager.getLastKnownLocation(LocationManager.PASSIVE_PROVIDER);
if (location != null) {
String londitude = " " + location.getLongitude();
String latitude = " " + location.getLatitude();
L1.setText(londitude);
L2.setText(latitude);
} else {
L1.setText("Enable Provider");
L2.setText("Enable Provider");
}
} catch (Exception e) {
};
B1.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
Refresh();
}
protected void Refresh() {
L1.setText(" ");
L2.setText(" ");
}
});
}
}