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 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 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
> > locationit 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 = 1; //
> > 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 1ms 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 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());
> >