hello i'm pretty new to android.. i'm making an application which needs exact(approx 50m accuracy acceptable) user location.. i'm using locationmanager and locationlistener.. whenever i start the application i need user location returned. problem is that onlocationchanged method in locationlistener returns the latitude longitude only when they change.. how do i get user location ?
locmgr.requestLocationUpdates(LocationManager.GPS_PROVIDER, 0, 0, loclist_netwk);
this is how i'm calling the class where i've implemented locationlistener.
`
package com.example.gpsmanager;
import android.app.Activity;
import android.content.Context;
import android.location.Location;
import android.location.LocationListener;
import android.os.Bundle;
import android.widget.TextView;
import android.widget.Toast;
public class MyLocationListener extends Activity implements LocationListener
{
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.mylocation_layout);
}
@Override
public void onLocationChanged(Location loc) {
// TODO Auto-generated method stub
loc.getLatitude();
loc.getLongitude();
String text="my current location is"+"lat: "+loc.getLatitude()+"long: "+loc.getLongitude();
//TextView text1=(TextView) findViewById(R.id.textView1);
//text1.setText(text+"");
Toast.makeText(MyLocationListener.this, text, Toast.LENGTH_LONG).show();
}
@Override
public void onProviderDisabled(String arg0) {
// TODO Auto-generated method stub
String text="GPS Provider not availabe";
}
@Override
public void onProviderEnabled(String arg0) {
// TODO Auto-generated method stub
String text="GPS Provider availabe";
}
@Override
public void onStatusChanged(String arg0, int arg1, Bundle arg2) {
// TODO Auto-generated method stub
}
}
` pllzz plzz help guys... thankss..