import android.app.Activity;
import android.content.*;
import android.location.*;
import android.os.Bundle;
import android.widget.Button;
import android.widget.EditText;
import android.view.View;;

public class LookAround extends Activity {
 LocationManager locManager;    //위치관리자
 String bestProvider;     //최적 위치제공자
 Double locLatitude, locLongitude;  //위치정보
 StringBuffer locationData;    //위치정보(string)
 public Location location;
 String lat = "오류";
 String lng = "오류";
 
 public void onCreate(Bundle savedInstanceState) {
  super.onCreate(savedInstanceState);
  setContentView(R.layout.lookaround);
  
  
  String context = Context.LOCATION_SERVICE;
  LocationManager lm = (LocationManager)getSystemService(context);
  
  //String provider = LocationManager.GPS_PROVIDER;
  
  //움직임 추적
  Criteria criteria = new Criteria();
  criteria.setAccuracy(Criteria.ACCURACY_FINE);
  criteria.setPowerRequirement(Criteria.POWER_LOW);
  criteria.setAltitudeRequired(false);
  criteria.setBearingRequired(false);
  criteria.setSpeedRequired(false);
  criteria.setCostAllowed(true);
  
  String provider = lm.getBestProvider(criteria, true);
  //움직임 추적
  
  Location location = lm.getLastKnownLocation(provider);
  
  updateWithNewLocation(location);
  
  //움직임 추적
  lm.requestLocationUpdates(provider, 2000, 10, locationListener);
  //움직임 추적
       
  Button btn_output = (Button)findViewById(R.id.btn_output);
  btn_output.setOnClickListener(new Button.OnClickListener() {
   public void onClick(View v) {
    EditText et_output = (EditText)findViewById(R.id.outputjsoc);
    et_output.setText("위도: "+lat +"경도: "+ lng);
   }
  });
 }
 
 
 private void updateWithNewLocation(Location loc) {
  
  
  if (loc != null) {//여기서 계속 널이랍니다;
   lat = String.valueOf(loc.getLatitude());
   lng = String.valueOf(loc.getLongitude());
  }else {lat = "loc 에러";}
  
 }
 
  
 private final LocationListener locationListener = new LocationListener(){

  //@Override
  public void onLocationChanged(Location arg0) {
   updateWithNewLocation(arg0);
  }

  //@Override
  public void onProviderDisabled(String arg0) {
   updateWithNewLocation(null);
  }

  //@Override
  public void onProviderEnabled(String arg0) {}

  //@Override
  public void onStatusChanged(String arg0, int arg1, Bundle arg2) {}
  
 };
    
}




소스를 보시면 아시겠지만 더할나위없이 간단 명료한 소스입니다.

기초중 기초로 짯는데 이상하게 1.6에뮬에선 돌아가는대 2.2 에뮬에선 location 이 null로 잡혀서 좌표를 못따오내요;;

에뮬레이터는 둘다 gps지원 켰습니다. 이런 거에서 막히니 황당하내요;; 짠프로그램이 잘안돌아가서 확인하니가 2.2에선 좌표를 못잡고있다니;

혹시 이유를 아시는분 계신가요??? 좀알려주세요 ㅠㅠ 도저희 모르겠내요 ㅠㅠ