Did u checked the code...............i think there can be problem in
the code also for reverse geocoding.......please check.......


On Feb 21, 7:53 pm, Mychandus Msb <mychan...@gmail.com> wrote:
> I got this error many times, this is not because of the code, this is
> because of device not able to get proper satellite signals. if you can get
> the device into open sky you may get the required inforamtion.
>
>
>
>
>
>
>
>
>
> On Tue, Feb 21, 2012 at 7:57 PM, ajay talreja <ajayt...@gmail.com> wrote:
> > I want to retrieve the address of the location when i am passing the
> > longitude and latitude from Command line through Telnet...The
> > application do get latitude and longitude updates when i change from
> > command line......
> > im providing with the code.......the code doesn't have any
> > error.........but is unable to show the address of the
> > location............it shows "LocationProvider.TEMPORARILY_UNAVAILABLE
> > "........If the service is not available how is it taking the values
> > from command line..........?????
> > i donno where i have gone wrong....... :-(
> > please help......
>
> > import java.io.IOException;
> > import java.text.SimpleDateFormat;
> > import java.util.Date;
> > import java.util.List;
> > import java.util.Locale;
>
> > import android.app.Activity;
> > import android.app.AlertDialog;
> > import android.content.DialogInterface;
> > import android.location.Address;
> > import android.location.Geocoder;
> > import android.location.Location;
> > import android.location.LocationListener;
> > import android.location.LocationManager;
> > import android.location.LocationProvider;
> > import android.os.Bundle;
> > import android.widget.TextView;
> > import android.widget.Toast;
>
> > public class GPSTest extends Activity implements LocationListener {
>
> >   private TextView mInfoText;
> >   private LocationManager mLoc;
>
> >   private static final Integer MINIMUM_UPDATE_INTERVAL = 10000; //
> > update every 10 seconds
> >   private static final Integer MINIMUM_UPDATE_DISTANCE = 10;    //
> > update every 10 meters
>
> >   /** Called when the activity is first created. */
> >   @Override
> >   public void onCreate(Bundle savedInstanceState) {
> >      super.onCreate(savedInstanceState);
> >      setContentView(R.layout.main);
>
> >      // get a handle to the text view to display the GPS location
> > data
> >      mInfoText = (TextView) findViewById(R.id.infotext);
>
> >      // the location manager allows access to the current location
> > and GPS status
> >      mLoc = (LocationManager) getSystemService(LOCATION_SERVICE);
> >   }
>
> >   @Override
> >   /**
> >    * onResume is is always called after onStart, even if the app
> > hasn't been paused
> >    */
> >   protected void onResume() {
> >      // add a location listener and request updates every 10000ms or
> > 10m
> >      mLoc.requestLocationUpdates(LocationManager.GPS_PROVIDER,
> > MINIMUM_UPDATE_INTERVAL,
> >            MINIMUM_UPDATE_DISTANCE, this);
> >      super.onResume();
> >   }
>
> >   @Override
> >   protected void onPause() {
> >      // GPS, as it turns out, consumes battery like crazy
> >      mLoc.removeUpdates(this);
> >      super.onPause();
> >   }
>
> >   @Override
> >   protected void onStop() {
> >      // may as well just finish since saving the state is not
> > important for this toy app
> >      finish();
> >      super.onStop();
> >   }
>
> >   public void onLocationChanged(Location loc) {
> >      // display some information based on the current position
> >      StringBuilder sb = new StringBuilder("Your current location is:\n
> > \n");
>
> >      sb.append("Longitude: ");
> >      sb.append(loc.getLongitude());
> >      sb.append('\n');
>
> >      sb.append("Latitude: ");
> >      sb.append(loc.getLatitude());
> >      sb.append('\n');
>
> >      sb.append("Altitiude: ");
> >      sb.append(loc.getAltitude());
> >      sb.append('\n');
>
> >      sb.append("Accuracy: ");
> >      sb.append(loc.getAccuracy());
> >      sb.append('\n');
>
> >      sb.append("Timestamp: ");
> >      Date timestamp = new Date(loc.getTime());
> >      sb.append(new SimpleDateFormat().format(timestamp));
>
> >      try{
> >          Geocoder gcd = new Geocoder(this, Locale.getDefault());
> >          List<Address> addresses =
> >              gcd.getFromLocation(loc.getLatitude(),
> > loc.getLongitude(),100);
> >          if (addresses.size() > 0) {
>
> >              StringBuilder result = new StringBuilder();
> >              for(int i = 0; i < addresses.size(); i++){
> >                  Address address =  addresses.get(i);
> >                  int maxIndex = address.getMaxAddressLineIndex();
> >                  for (int x = 0; x <= maxIndex; x++ ){
> >                      result.append(address.getAddressLine(x));
>
> >                      result.append(",");
> >                  }
> >                  result.append(address.getLocality());
> >                  result.append(",");
> >                  result.append(address.getPostalCode());
> >                  result.append("\n\n");
> >              }
> >              sb.append(result.toString());
> >          }
> >      }
> >      catch(IOException ex){
> >         sb.append(ex.getMessage().toString());
> >      }
>
> >      mInfoText.setText(sb.toString());
> >   }
>
> >   public void onProviderDisabled(String provider) {
> >      // called if/when the GPS is disabled in settings
> >      Toast.makeText(this, "GPS disabled", Toast.LENGTH_LONG).show();
>
> >      // end program since we depend on GPS
> >      AlertDialog.Builder alertbox = new AlertDialog.Builder(this);
> >      alertbox.setMessage("This demo app requires GPS. Please activate
> > it first!");
> >      alertbox.setNeutralButton("Ok", new
> > DialogInterface.OnClickListener() {
> >          public void onClick(DialogInterface arg0, int arg1) {
> >             finish();
> >          }
> >      });
> >      alertbox.show();
> >   }
>
> >   public void onProviderEnabled(String provider) {
> >      Toast.makeText(this, "GPS enabled", Toast.LENGTH_LONG).show();
> >   }
>
> >   public void onStatusChanged(String provider, int status, Bundle
> > extras) {
> >      // called upon GPS status changes
> >      switch (status) {
> >      case LocationProvider.OUT_OF_SERVICE:
> >         Toast.makeText(this, "Status changed: out of service",
> > Toast.LENGTH_LONG).show();
> >         break;
> >      case LocationProvider.TEMPORARILY_UNAVAILABLE:
> >         Toast.makeText(this, "Status changed: temporarily
> > unavailable", Toast.LENGTH_LONG).show();
> >         break;
> >      case LocationProvider.AVAILABLE:
> >         Toast.makeText(this, "Status changed: available",
> > Toast.LENGTH_LONG).show();
> >         break;
> >      }
> >   }
> > }
>
> > --
> > You received this message because you are subscribed to the Google
> > Groups "Android Developers" group.
> > To post to this group, send email to android-developers@googlegroups.com
> > To unsubscribe from this group, send email to
> > android-developers+unsubscr...@googlegroups.com
> > For more options, visit this group at
> >http://groups.google.com/group/android-developers?hl=en
>
> --
> CHANDRA_MBS

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to