package kr.co.wijibook.google_map_service;

//import android.app.Activity;
import android.os.Bundle;
import com.google.android.maps.MapActivity;
import com.google.android.maps.MapView;
import com.google.android.maps.MapController;
import com.google.android.maps.GeoPoint;
import android.location.Location;
import android.location.LocationManager;
import android.location.LocationListener;
import android.content.Context;

import android.widget.Toast;


public class GetContactsActivity extends MapActivity { 
 
 LocationListener mLocationListener;
 MapView mapView;
 MapController mc;
 
    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
       
        mapView = (MapView)findViewById(R.id.mapview);
        mapView.setBuiltInZoomControls(true);
        mapView.setSatellite(true);
       
        LocationManager lm
        =(LocationManager) getSystemService(Context.LOCATION_SERVICE);
         mc = mapView.getController();
         
         mLocationListener = new LocationListener(){
          public void onLocationChanged(Location location){
           if(location != null){
            Toast.makeText(
              getBaseContext(),
              "위도는 " + location.getLatitude() + ", " + "경도는 " +
              location.getLongitude() + " 입니다  " , Toast.LENGTH_SHORT)
              .show();
            
                 GeoPoint gp = new GeoPoint((int) (location.getLatitude() * 1000000),
                   (int)(location.getLongitude() * 1000000));
                
                 mc.animateTo(gp);
                 mc.setZoom(14);
                
           }
          }
          public void onProviderDisabled(String arg0){
           
          }
          public void onProviderEnabled(String arg0){
           
          }
          public void onStatusChanged(String arg0, int arg1, Bundle arg2){
           
          }
         };
          lm.requestLocationUpdates(LocationManager.GPS_PROVIDER,
          0, 2, mLocationListener);

    }
    @Override
     protected boolean isRouteDisplayed(){
      return false;
    }
    @Override
    public void onDestroy(){
     super.onDestroy();
     LocationManager lm
     = (LocationManager)getSystemService(Context.LOCATION_SERVICE);
     lm.removeUpdates(mLocationListener);
    }
}

어플 실행을 하면 응용프로그램이 예상치 않게 중지 되었습니다. 이렇게 뜨고 종료되네요

 

          lm.requestLocationUpdates(LocationManager.GPS_PROVIDER,
          0, 2, mLocationListener);  이부분을 없애고 돌리면 돌아가긴 하는데 제 위치가 안뜨고요...

도와주세요 ㅜㅜ