package altest1.test1;

import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;
import java.util.GregorianCalendar;
import java.util.Locale;
import java.util.Random;

import android.app.Activity;
import android.app.AlertDialog;
import android.os.Bundle;
import android.view.MotionEvent;
import android.widget.ImageView;


public class Altest1Activity extends Activity {
    Random rd = new Random();
    int time = (rd.nextInt(10)+1)*1000;
    public int time1;
    public int time2;
    public int time3;
    ImageView mImageView;
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        
        
        setContentView(R.layout.main);
        
        savetime(time1);
        try{
        Thread.sleep(time);
        }catch(InterruptedException e){
        savetime(time2);
        mImageView = (ImageView)findViewById(R.id.img1);
        //AlertDialog.Builder dlg = new AlertDialog.Builder(Altest1Activity.this);
        //dlg.setTitle("걸린시간");
        //dlg.setMessage(time2);
        //dlg.setIcon(R.drawable.ic_launcher);
        //dlg.show();
        }
        
        
    }
    public boolean onTouchEvent(MotionEvent event) {
        
    if(event.getAction() == MotionEvent.ACTION_DOWN){
    time3=nowtime();
    int temp=time2-time1;
    String rt=String.valueOf(time3);
    String rt1=String.valueOf(time2);
    String rt2=String.valueOf(time1);
   
        AlertDialog.Builder dlg = new AlertDialog.Builder(Altest1Activity.this);
        dlg.setTitle("걸린시간");
        dlg.setMessage(rt+"time1= "+rt1+"time2= "+rt2);
        dlg.setIcon(R.drawable.ic_launcher);
        dlg.show();
    }
        return true;

    }
    public int nowtime() {
    int result;
     Calendar cal = new GregorianCalendar();
     int mHour = cal.get(Calendar.HOUR_OF_DAY);
     int mMinute = cal.get(Calendar.MINUTE);
     int mSecond = cal.get(Calendar.SECOND);
     int mMilliSecond = cal.get(Calendar.MILLISECOND);
     result = mHour*3600000+mMinute*60000+mSecond*1000+mMilliSecond;
     return result;
    }
    public void savetime(int time){
    time=nowtime();
    }
}


굵은 글씨가 현재 시간을 저장하는 코드인데요.
마지막에 출력을 하면 time3을제외한 time1,time2가 0으로 초기화가 되버려요 ㅠㅠ
어떤 이유인가요 ㅠㅠ
메서드를 하나 만들어서 저렇게 저장하게 했는데도 저러네요 ㅠㅠ