앱을 실행시키면은...
gps 좌표를 받은 값을 서버로 전송하려고합니다..
약 5초 주기를 반복으로 값을 서버에 전송시킬려고하는데..
지금 timer로 해봤는데..
오류가납니다..
어떤식으로 해야할까요...
조언부탁드립니다..!!
05-03 07:34:15.933: E/AndroidRuntime(377): FATAL EXCEPTION: main
05-03 07:34:15.933: E/AndroidRuntime(377): java.lang.RuntimeException: Unable to start activity ComponentInfo{taxi.project/taxi.project.locationActivity}: java.lang.NullPointerException
05-03 07:34:15.933: E/AndroidRuntime(377): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1647)
05-03 07:34:15.933: E/AndroidRuntime(377): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1663)
05-03 07:34:15.933: E/AndroidRuntime(377): at android.app.ActivityThread.access$1500(ActivityThread.java:117)
05-03 07:34:15.933: E/AndroidRuntime(377): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:931)
05-03 07:34:15.933: E/AndroidRuntime(377): at android.os.Handler.dispatchMessage(Handler.java:99)
05-03 07:34:15.933: E/AndroidRuntime(377): at android.os.Looper.loop(Looper.java:130)
05-03 07:34:15.933: E/AndroidRuntime(377): at android.app.ActivityThread.main(ActivityThread.java:3683)
05-03 07:34:15.933: E/AndroidRuntime(377): at java.lang.reflect.Method.invokeNative(Native Method)
05-03 07:34:15.933: E/AndroidRuntime(377): at java.lang.reflect.Method.invoke(Method.java:507)
05-03 07:34:15.933: E/AndroidRuntime(377): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
05-03 07:34:15.933: E/AndroidRuntime(377): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
05-03 07:34:15.933: E/AndroidRuntime(377): at dalvik.system.NativeStart.main(Native Method)
05-03 07:34:15.933: E/AndroidRuntime(377): Caused by: java.lang.NullPointerException
05-03 07:34:15.933: E/AndroidRuntime(377): at taxi.project.locationActivity.onCreate(locationActivity.java:55)
05-03 07:34:15.933: E/AndroidRuntime(377): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
05-03 07:34:15.933: E/AndroidRuntime(377): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1611)
이렇게 로그캣이뜹니다..
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.mapview);
mapView = (MapView) findViewById(R.id.mapview);
mapView.setBuiltInZoomControls(true);
// load GPS( GPS 로 부터 현재의 내 위치 가져오기 )
loadGps();// location 값할당
List<Overlay> mapOverlays = mapView.getOverlays();
Drawable drawable = this.getResources().getDrawable(R.drawable.ic_launcher);
MyItemizedOverlay itemizedoverlay = new MyItemizedOverlay(drawable,this);
GeoPoint point = new GeoPoint((int)(37.5643406*1E6),(int)(126.9756087*1E6));
//GeoPoint point = new GeoPoint((int) (location.getLatitude() * 1E6),(int) (location.getLongitude() * 1E6));
OverlayItem overlayitem = new OverlayItem(point, "Hi Pondol!","I'm in Seoul!");
itemizedoverlay.addOverlay(overlayitem);
mapController = mapView.getController();
mapController.setCenter(point);
mapController.setZoom(15); //
mapController.animateTo(point);
mapOverlays.add(itemizedoverlay);
latPoint = location.getLatitude();
Log.i("aa", ""+latPoint);
lngPoint = location.getLongitude();
Log.i("bb", ""+lngPoint);
mTimer = new Timer();
mTimer.schedule(new TimerTask() {
@Override
public void run() {
TimerMethod(); // 지정된 시간에 실행할 메소드
}
}, 3000); // 밀리세컨드 단위로 딜레이될 시간
}
private void TimerMethod() {
// Intent intent = new Intent(main.this, EmpActivity.class);
// startActivity(intent);
// count++;
// Toast.makeText(locationActivity.this, "good", 0).show();
// TextView a = (TextView)findViewById(R.id.text);
// a.setText(count);
mTimer.cancel(); // 타이머를 취소하지 않으면 계속 실행이 된다.
// finish(); // finish를 하지 않으면 뒤로가기 버튼을 누를 때 스플래쉬 화면으로 간다.
} 소스는 이렇게짯어요..!!




로그캣을 올려주시면 조언을 해드리지요