Wednesday, February 1, 2012

[android-developers] Re: android help

have tried as you told to change "Try getting the location through a
location update. (Use
requestLocationUpdate() or requestSingleUpdate() instead.)"

but it is also not working for me........providing the code for your
review......

Code:
"gps12.java "
package d.gps12;


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.widget.TextView;

public class gps12 extends Activity {
/** Called when the activity is first created. */
TextView t1,t2;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
LocationManager lm = (LocationManager)
getSystemService(Context.LOCATION_SERVICE);
LocationListener ll = new mylocationlistener();
lm.requestLocationUpdates(LocationManager.GPS_PROVIDER, 0, 0,
ll);
t1=(TextView) findViewById(R.id.TextView01);
t2=(TextView) findViewById(R.id.TextView02);

t1.setText("hii");
t2.setText("hiiii");
}

private class mylocationlistener implements LocationListener {
public void onLocationChanged(Location location) {
if (location != null) {
t1.setText((int) location.getLatitude());
t2.setText((int) location.getLongitude());

}

else
{
t1.setText("unable");
t2.setText("unable");

}
}

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

}
}

After launching this application, I'm passing latitude and long.
values from emulator and have also tried passing from command line
through telnet ..but location values seems to be empty so.......the
latitude and long. values are not getting displayed.........
and the "text view" are not changing the values.....it means that
"location changed " method is not getting execute neither its "if"
part nor its "else" part......so what might be the problem........


isn't the code correct or what might be the other
problems..........???
please get it run on your system.... help please......

thanks........

--
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+unsubscribe@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

No comments:

Post a Comment