Basic Timer For Android

Here is a basic timer for Android in Eclipse/ Java.  I’ve simply modified the example shown in the link here by declaring the delay/period as global variables (measured in milliseconds) / implementing my own ‘tasks’ in the void run

http://www.exampledepot.com/egs/java.util/ScheduleRepeat.html

	public void onClick(final View view) {

		timer.scheduleAtFixedRate(new TimerTask() {
		        public void run() {
		    		results = wifi.getScanResults();
		    		textStatus.setText("number of networks: " + results.size());
			    		if (view.getId() == R.id.buttonScan) {
			    			Log.d(TAG, "onClick() wifi.startScan()");
			    			wifi.startScan();
			    		}
		        }
		    }, delay, period);

	}
Advertisements
This entry was posted in Uncategorized. Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s