gps프로그램 작성하는데요 이클립스를 이용하는데
아무런 오류발생하지 않는데 에뮬레이터로 돌리면
The application MyLocationDemoActivity01(process ac.kr.MyLocationDemoActivity01) has stopped unexpectedly.
please try again
메시지가 뜹니다
소스코드는 아래와 같구요 무슨 문제인지 모르겠네요 ㅠ
도와주세요
package kr.ac.MyLocationDemoActivity01;
import com.google.android.maps.GeoPoint;
import com.google.android.maps.MapActivity;
import com.google.android.maps.MapView;
import com.google.android.maps.MyLocationOverlay;
import android.content.Context;
import android.location.Location;
import android.location.LocationListener;
import android.location.LocationManager;
import android.widget.Toast;
import ac.kr.MyLocationDemoActivity01.R;
import android.os.Bundle;
public class MyLocationDemoActivity01Main extends MapActivity {
/** Called when the activity is first created. */
MapView mapView = null;
MyLocationOverlay whereAmI = null;
LocationManager locMgr = null;
LocationListener locListener = null;
@Override
protected boolean isLocationDisplayed() {
return whereAmI.isMyLocationEnabled();
}
@Override
protected boolean isRouteDisplayed() {
// TODO Auto-generated method stub
return false;
}
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
mapView = (MapView)findViewById(R.id.geoMap);
mapView.setBuiltInZoomControls(true);
mapView.getController().setZoom(15);
whereAmI = new MyLocationOverlay(this, mapView);
mapView.getOverlays().add(whereAmI);
mapView.postInvalidate();
locMgr = (LocationManager)getSystemService(Context.LOCATION_SERVICE);
locListener = new LocationListener() {
public void onLocationChanged(Location location){
showLocation(location);
}
public void onProviderDisabled(String provider)
{
}
public void onProviderEnabled(String provider)
{
}
public void onStatusChanged(String provider, int status, Bundle extras)
{
}
};
}
@Override
public void onResume() {
super.onResume();
Location lastLoc = locMgr.getLastKnownLocation(LocationManager.GPS_PROVIDER);
showLocation(lastLoc);
locMgr.requestLocationUpdates(LocationManager.GPS_PROVIDER, 0, 0, locListener);
whereAmI.enableMyLocation();
whereAmI.runOnFirstFix(new Runnable() { public void run(){ mapView.getController().setCenter(whereAmI.getMyLocation());
}
});
}
@Override
public void onPause(){
super.onPause();
locMgr.removeUpdates(locListener);
whereAmI.disableMyLocation();
}
private void showLocation(Location location) {
if (location !=null)
{
double lat = location.getLatitude();
double lng = location.getLongitude();
GeoPoint myLocation = new GeoPoint((int)(lat*1000000),(int)(lng*1000000));
Toast.makeText(getBaseContext(), "New location latitude [" + lat + "] longitude [" + lng + "]", Toast.LENGTH_SHORT).show();
mapView.getController().animateTo(myLocation);
}
}
}