Checkout the logcat for details.
On Jan 22, 12:37 am, Matt <[email protected]> wrote: > Hello, > > Im new to android dev, and am getting a force close on my first > application and I cant figure it out for the life of me. Hope someone > can spot it! > > import android.app.Activity; > import android.os.Bundle; > import android.os.Handler; > import android.os.SystemClock; > import android.view.View; > import android.view.View.OnClickListener; > import android.widget.Button; > import android.widget.TextView; > > public class inputTest extends Activity { > > private Handler mHandler = new Handler(); > public long mStartTime; > > /** Called when the activity is first created. */ > @Override > public void onCreate(Bundle savedInstanceState) { > > super.onCreate(savedInstanceState); > > setContentView(R.layout.main); > > buttonStart.setOnClickListener(mStartListener); > buttonStop.setOnClickListener(mStopListener); > > } > > Button buttonStart = (Button) findViewById(R.id.button_start); > Button buttonStop = (Button) findViewById(R.id.button_stop); > TextView timer = (TextView)findViewById(R.id.timer); > > OnClickListener mStartListener = new OnClickListener () { > public void onClick (View v) { > if (mStartTime == 0L){ > mStartTime = System.currentTimeMillis(); > mHandler.removeCallbacks(mUpdateTimeTask); > mHandler.postDelayed(mUpdateTimeTask, 100); > } > } > }; > > OnClickListener mStopListener = new OnClickListener() { > public void onClick(View v) { > mHandler.removeCallbacks(mUpdateTimeTask); > } > }; > > private Runnable mUpdateTimeTask = new Runnable() { > public void run() { > final long start = mStartTime; > long millis = SystemClock.uptimeMillis() - start; > int seconds = (int) (millis / 1000); > int minutes = seconds / 60; > seconds = seconds % 60; > > if (seconds < 10) { > timer.setText("" + minutes + ":0" + seconds); > } else { > timer.setText("" + minutes + ":" + > seconds); > } > > mHandler.postAtTime(this, > start + (((minutes * 60) + seconds + 1) * 1000)); > } > }; > > } -- You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/android-developers?hl=en

