android:background="#ffffffff"
>
<TextView
+ android:id="@+id/tv"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
+ android:gravity="center"
android:layout_weight="1"
android:textColor="#ff000000"
android:text="Hello, WhereAmI?!"
import android.app.Activity;
import android.os.Bundle;
+import android.os.AsyncTask;
+import android.util.Log;
+import android.view.View;
import android.view.Window;
import android.view.WindowManager;
+import android.widget.TextView;
public class WhereAmI extends Activity
{
getWindow().addFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN);
getWindow().clearFlags(WindowManager.LayoutParams.FLAG_FORCE_NOT_FULLSCREEN);
setContentView(R.layout.main);
+ Log.v("WhereAmI", "created UI, about to start update task");
+ new TimedUpdateTask().execute(5);
+ Log.v("WhereAmI", "created UI, update task created");
+ }
+
+ private class TimedUpdateTask extends AsyncTask<Integer, Void, String> {
+ @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);
+ }
}
}