From d837c7a854c5e53867641b519a33d545b929c52e Mon Sep 17 00:00:00 2001 From: Eugene Crosser Date: Wed, 25 Jan 2012 20:51:07 +0400 Subject: [PATCH] Use async task --- res/layout/main.xml | 2 ++ src/org/average/whereami/WhereAmI.java | 28 ++++++++++++++++++++++++++ 2 files changed, 30 insertions(+) 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); + } } } -- 2.43.0