import android.text.format.Time;
 import android.util.Log;
 import android.view.View;
+import android.view.KeyEvent;
 import android.view.Menu;
 import android.view.MenuInflater;
 import android.view.MenuItem;
     private SharedPreferences prefs;
     private PersistentStore store;
     private Random random = new Random();
+    private Boolean revive = false;
+    private Context context;
 
     private class UpdateTarget {
         private TextView tv;
 
     private Handler mHandler = new Handler();
 
+    private Runnable reviveSelf = new Runnable() {
+        public void run() {
+            Log.v(TAG, "trying to revive self");
+            Intent intent = new Intent(Intent.ACTION_MAIN);
+            intent.addCategory(Intent.CATEGORY_LAUNCHER );
+            intent.setClass(context, WhereAmI.class);
+            intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
+            intent.addFlags(Intent.FLAG_ACTIVITY_RESET_TASK_IF_NEEDED);
+            intent.addFlags(Intent.FLAG_FROM_BACKGROUND);
+            intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
+            startActivity(intent);
+        }
+    };
+
     private Runnable updateClock = new Runnable () {
         public void run() {
             long now = System.currentTimeMillis();
     @Override
     public void onCreate(Bundle savedInstanceState) {
         super.onCreate(savedInstanceState);
+        context = this;
         if (Build.VERSION.SDK_INT <= Build.VERSION_CODES.FROYO) {
             Log.v(TAG, "Disabling keepalive for build version " +
                        Build.VERSION.SDK_INT);
         } else {
             getWindow().clearFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN);
         }
+        revive = true;
        mHandler.post(updateClock);
        mHandler.post(updateCal);
        mHandler.post(updateInfo);
        mHandler.removeCallbacks(updateClock);
        mHandler.removeCallbacks(updateCal);
        mHandler.removeCallbacks(updateInfo);
+        if (revive) {
+            Log.v(TAG, "scheduling revival");
+           mHandler.postDelayed(reviveSelf, 6000); // 6 second delay
+        }
     }
 
     /** Called when the activity is destroyed. */
     public boolean onOptionsItemSelected(MenuItem item) {
         switch (item.getItemId()) {
         case R.id.quit:
+            revive = false;
             finish();
             return true;
         case R.id.authorize:
             return super.onOptionsItemSelected(item);
         }
     }
+
+    /** Override "back" button. Can still quit via menu. */
+    @Override
+    public boolean onKeyDown(int keyCode, KeyEvent event) {
+        if (keyCode == KeyEvent.KEYCODE_BACK) {
+            return true;
+        }
+       return super.onKeyDown(keyCode, event);
+    }
 }