만보기 어플 만드는 중 도저히 안되는부분이 있어서 질문 드립니다.

 

package jo.pakage;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Locale;
import android.app.Activity;
import android.app.AlertDialog;
import android.content.DialogInterface;
import android.content.Intent;
import android.hardware.Sensor;
import android.hardware.SensorEvent;
import android.hardware.SensorEventListener;
import android.hardware.SensorManager;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.TextView;
import android.widget.Toast;
public class Manbocount extends Activity implements SensorEventListener{
  
 
 //센서
     private SensorManager sensorManager; 
     private Sensor accelerormeterSensor; 
     private long lastTime; 
     private float speed; 
     private float lastX; 
     private float lastY; 
     private float lastZ; 
     private float x, y, z;
     public int count = 0;
     public double cal = 0;
     String str = String.format("%d",count);
     String str1 = String.format("%d",cal);
     private static final int DATA_X = SensorManager.DATA_X; 
     private static final int DATA_Y = SensorManager.DATA_Y; 
     private static final int DATA_Z = SensorManager.DATA_Z; 
 //시간 호출
 TextView Date;
 TextView Counter;
 TextView Calcounter;
 Button EndButton;
 Button StartButton;
    SimpleDateFormat formater = new SimpleDateFormat("MM",Locale.KOREA);
    SimpleDateFormat formater1 = new SimpleDateFormat("dd",Locale.KOREA);
    Date current = new Date();
    Date current1 = new Date();
    String time = formater.format(current);
    String time1 = formater1.format(current1);
    
    
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.running);
        // 날짜 표현
        Date = (TextView)findViewById(R.id.date);
        Date.setText(time+"월"+time1+"일");
  
        //스타트 버튼시 카운터 시작을 위한 센서선언
        StartButton = (Button)findViewById(R.id.start);
        StartButton.setOnClickListener(new Button.OnClickListener(){
         public void onClick(View v){
          Toast.makeText(Manbocount.this,"시작~~!!",0).show();
          sensorManager = (SensorManager)getSystemService(SENSOR_SERVICE);
          accelerormeterSensor = sensorManager.getDefaultSensor(Sensor.TYPE_ACCELEROMETER);
          Counter = (TextView)findViewById(R.id.count);
          Calcounter = (TextView)findViewById(R.id.cal);              
           }   
         });
        
        
        //종료 버튼시
        EndButton = (Button)findViewById(R.id.stop);
        EndButton.setOnClickListener(new Button.OnClickListener(){
         public void onClick(View v){
          new AlertDialog.Builder(Manbocount.this)
          .setTitle("끝??")
          .setMessage("벌써 끝낼려구요?")
          .setIcon(R.drawable.uu)
          .setPositiveButton("엉",new DialogInterface.OnClickListener() {
     public void onClick(DialogInterface dialog, int which) {
      Intent intent = new Intent(Manbocount.this,Manboend.class);
      startActivity(intent);
     }
    })
    .setNegativeButton("아니",null)
    .show();
         }
        });
    }
        
    
//센서 호출    
    
public void onResume() { 
         super.onResume(); 
         if (accelerormeterSensor != null) 
             sensorManager.registerListener(this, accelerormeterSensor, 
                     SensorManager.SENSOR_DELAY_GAME); 
     } 
     @Override 
     public void onPause() { 
         super.onPause(); 
         if (sensorManager != null) 
             sensorManager.unregisterListener(this); 
     } 
     
     
     @Override 
     public void onAccuracyChanged(Sensor sensor, int accuracy) { 
     } 
     
     @Override 
  public void onSensorChanged(SensorEvent event) {
   if (event.sensor.getType() == Sensor.TYPE_ACCELEROMETER) {
    long currentTime = System.currentTimeMillis();
    long gabOfTime = (currentTime - lastTime);
    if (gabOfTime > 100) {
     lastTime = currentTime;
     x = event.values[SensorManager.DATA_X];
     y = event.values[SensorManager.DATA_Y];
     z = event.values[SensorManager.DATA_Z];
     speed = Math.abs(x + y + z - lastX - lastY - lastZ) /
     gabOfTime * 10000;
     if (speed > 800) {
      count++;
      str = String.format("%d", count);
      Counter.setText(str);
      cal = count * 0.033;
      str1 = String.format("%d", cal);
      Calcounter.setText("빠지고있어요!!  "+ str1 +" cal~!");
     }
     lastX = event.values[DATA_X];
     lastY = event.values[DATA_Y];
     lastZ = event.values[DATA_Z];
    }
   }
  }
}


 

시작 버튼을 누를 시 센서이벤트리스너를 통해서 값을받아 흔들림을 감지할때마다 카운터를 증가시킬려고 만들었습니다.

 

날짜 입력과 종료시 다음엑티비티를 호출하는 것 까지는 됬으나

 

센서를 통한 카운터증가 소스를 추가하면서부터 진행이 되질 않내요....

 

아직 시작한지 얼마 되지 않아 도저히 찾아보려해도 찾아지지가 않아서 여쭙니다....ㅜㅜ;;