This is my first android app and I feel like it should be simple but I had my code working then I added two button in my xml file and added a switch/case clause and now im getting an error... eclipse error log is not recording what the error is and no other error messages... the way my app works is it collects username, password and group and them it switches to my main xml where I am getting the error... any help would be appreciated
<?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/ android" android:orientation="vertical" android:layout_width="fill_parent" android:layout_height="fill_parent"> <Button android:id="@+id/retrieve_location_button" android:text="Retrieve Location" android:layout_width="wrap_content" android:layout_height="wrap_content" /> <TextView android:id="@+id/tvMessage" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="TextView" /> <TextView android:id="@+id/tvPassworded" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="TextView" /> <TextView android:id="@+id/tVLast" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="TextView" /> <TextView android:text="TextView" android:id="@+id/tvLat" android:layout_width="wrap_content" android:layout_height="wrap_content"></TextView> <TextView android:text="TextView" android:id="@+id/tvLong" android:layout_width="wrap_content" android:layout_height="wrap_content"></TextView> <TextView android:text="TextView" android:id="@+id/tvconnecting" android:layout_width="wrap_content" android:layout_height="wrap_content"></TextView> <Button android:text="Pause" android:id="@+id/bPause" android:layout_width="fill_parent" android:layout_height="wrap_content"></Button> <Button android:text="Resume" android:id="@+id/bResume" android:layout_width="fill_parent" android:layout_height="wrap_content"></Button> <Button android:text="Quit" android:id="@+id/bQuit" android:layout_width="fill_parent" android:layout_height="wrap_content"></Button> </LinearLayout> and I added a switch and case to my LbsGeocodingActivity class import java.io.BufferedReader; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.util.ArrayList; import org.apache.http.HttpEntity; import org.apache.http.HttpResponse; import org.apache.http.NameValuePair; import org.apache.http.client.HttpClient; import org.apache.http.client.entity.UrlEncodedFormEntity; import org.apache.http.client.methods.HttpPost; import org.apache.http.impl.client.DefaultHttpClient; import org.apache.http.message.BasicNameValuePair; import android.app.Activity; import android.content.Context; import android.location.Location; import android.location.LocationListener; import android.location.LocationManager; import android.os.Bundle; import android.util.Log; import android.view.View; import android.view.View.OnClickListener; import android.widget.Button; import android.widget.RadioGroup; import android.widget.RadioGroup.OnCheckedChangeListener; import android.widget.TextView; import android.widget.TextView.BufferType; import android.widget.Toast; public class LbsGeocodingActivity extends Activity implements OnClickListener, OnCheckedChangeListener { private static final long MINIMUM_DISTANCE_CHANGE_FOR_UPDATES = 1; // in // Meters private static final long MINIMUM_TIME_BETWEEN_UPDATES = 1000; // in // Milliseconds protected LocationManager locationManager; protected Button retrieveLocationButton; protected Button resumebutton; protected Button pausebutton; protected Button quitbutton; public double longi; public double lati; TextView question, test, pwrd, longitudinal, lititudinal; static TextView connecting; String gotBread, teat, lockerroom, spotX, spotY; @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); retrieveLocationButton = (Button) findViewById(R.id.retrieve_location_button); resumebutton =(Button)findViewById(R.id.bResume); pausebutton=(Button)findViewById(R.id.bPause); quitbutton=(Button)findViewById(R.id.bQuit); locationManager = (LocationManager) getSystemService(Context.LOCATION_SERVICE); locationManager.requestLocationUpdates(LocationManager.GPS_PROVIDER, MINIMUM_TIME_BETWEEN_UPDATES, MINIMUM_DISTANCE_CHANGE_FOR_UPDATES, new MyLocationListener()); intialize(); Bundle gotBasket = getIntent().getExtras(); Bundle teatime = getIntent().getExtras(); gotBread = gotBasket.getString("key"); teat = teatime.getString("lock"); lockerroom = teatime.getString("combo"); question.setText(gotBread); pwrd.setText(teat); test.setText(lockerroom); retrieveLocationButton.setOnClickListener(this); resumebutton.setOnClickListener(this); pausebutton.setOnClickListener(this); quitbutton.setOnClickListener(this); } @Override public void onClick(View arg0) { switch(arg0.getId()){ case R.id.retrieve_location_button: showCurrentLocation(); break; case R.id.bPause: onPause(); break; case R.id.bQuit: onDestroy(); break; case R.id.bResume: onResume(); break; } // TODO Auto-generated method stub } protected void showCurrentLocation() { Location location = locationManager .getLastKnownLocation(LocationManager.GPS_PROVIDER); if (location != null) { String message = String.format( "Current Location \n Longitude: %1$s \n Latitude: %2$s", location.getLongitude(), location.getLatitude()); longi = location.getLongitude(); lati = location.getLatitude(); lititudinal.setText("Lat " + lati); longitudinal.setText("Log " + longi); // String secondDouble = Double.toString(value); spotX = Double.toString(lati); spotY = Double.toString(longi); putServerData(gotBread, teat, lockerroom, spotX, spotY); Toast.makeText(LbsGeocodingActivity.this, message, Toast.LENGTH_LONG).show(); } } private class MyLocationListener implements LocationListener { public void onLocationChanged(Location location) { String message = String.format( "New Location \n Longitude: %1$s \n Latitude: %2$s", location.getLongitude(), location.getLatitude()); longi = location.getLongitude(); lati = location.getLatitude(); spotX = Double.toString(lati); spotY = Double.toString(longi); putServerData(gotBread, teat, lockerroom, spotX, spotY); Toast.makeText(LbsGeocodingActivity.this, message,Toast.LENGTH_LONG).show(); } public void onStatusChanged(String s, int i, Bundle b) {Location location = locationManager .getLastKnownLocation(LocationManager.GPS_PROVIDER); if (location != null) { //String message = String.format( // "Current Location \n Longitude: %1$s \n Latitude: %2$s", // location.getLongitude(), location.getLatitude()); longi = location.getLongitude(); lati = location.getLatitude(); lititudinal.setText("Lat " + lati); longitudinal.setText("Log " + longi); // String secondDouble = Double.toString(value); spotX = Double.toString(lati); spotY = Double.toString(longi); putServerData(gotBread, teat, lockerroom, spotX, spotY); //Toast.makeText(LbsGeocodingActivity.this, message, // Toast.LENGTH_LONG).show(); } } public void onProviderDisabled(String s) { Toast.makeText(LbsGeocodingActivity.this, "Provider disabled by the user. GPS turned off", Toast.LENGTH_LONG).show(); } public void onProviderEnabled(String s) { Toast.makeText(LbsGeocodingActivity.this, "Provider enabled by the user. GPS turned on", Toast.LENGTH_LONG).show(); } } @Override public void onCheckedChanged(RadioGroup arg0, int arg1) { // TODO Auto-generated method stub } public void onResume(){ showCurrentLocation(); } public void onPause(){ super.onPause(); } public void onDestroy(){ super.onDestroy(); } public void intialize() { question = (TextView) findViewById(R.id.tvMessage); pwrd = (TextView) findViewById(R.id.tvPassworded); test = (TextView) findViewById(R.id.tVLast); connecting = (TextView) findViewById(R.id.tvconnecting); lititudinal = (TextView) findViewById(R.id.tvLat); longitudinal = (TextView) findViewById(R.id.tvLong); } public void putServerData(String gotBread, String teat, String lockerroom, String spotX, String spotY) { String db_url = "http://www.semsnation.com/loaddata.php"; InputStream is = null; ArrayList<NameValuePair> request = new ArrayList<NameValuePair>(); request.add(new BasicNameValuePair("User", gotBread)); request.add(new BasicNameValuePair("Password1", teat)); request.add(new BasicNameValuePair("Group1", lockerroom)); request.add(new BasicNameValuePair("Latitude", spotX)); request.add(new BasicNameValuePair("Longitude", spotY)); try { HttpClient httpclient = new DefaultHttpClient(); Log.e("log_tag", "Got this far " + httpclient); HttpPost httppost = new HttpPost(db_url); httppost.setEntity(new UrlEncodedFormEntity(request)); HttpResponse response = httpclient.execute(httppost); HttpEntity entity = response.getEntity(); is = entity.getContent(); String s = convertStreamToString(is); connecting.setText("got this far " + response); Log.e("log_tag", "Result: " + s); } catch (Exception e) { e.printStackTrace(); connecting.setText("error" + e.toString()); Log.e("log_tag", "Error: " + e.toString()); }// catch }// send private String convertStreamToString(InputStream is) { BufferedReader reader = new BufferedReader(new InputStreamReader(is)); StringBuilder sb = new StringBuilder(); String line = null; try { while ((line = reader.readLine()) != null) { sb.append(line + "\n"); } } catch (IOException e) { e.printStackTrace(); } finally { try { is.close(); } catch (IOException e) { e.printStackTrace(); }// catch }// finally return sb.toString(); }// convertstreamtostring } -- You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/android-developers?hl=en

