From: Eugene Crosser Date: Wed, 25 Jan 2012 16:51:07 +0000 (+0400) Subject: Use async task X-Git-Url: http://average.org/gitweb/?a=commitdiff_plain;h=d837c7a854c5e53867641b519a33d545b929c52e;p=WhereAmI.git Use async task --- diff --git a/res/layout/main.xml b/res/layout/main.xml index 659a7db..cb95f7a 100644 --- a/res/layout/main.xml +++ b/res/layout/main.xml @@ -6,8 +6,10 @@ android:background="#ffffffff" > { + @Override + protected String doInBackground(Integer... howlong) { + Log.v("TimedUpdateTask", "starting"); + try { + Thread.sleep(1000 * howlong[0]); + } catch (InterruptedException e) { + Log.e("TimedUpdateTask", "sleep interrupted"); + } + Log.v("TimedUpdateTask", "about to return"); + return (Integer.toString(howlong[0]) + " seconds passed"); + } + + @Override + protected void onPostExecute(String str) { + TextView tv = (TextView)findViewById(R.id.tv); + Log.v("TimedUpdateTask", "callback executing"); + tv.append("\n" + str); + } } }