OSDN Git Service

Make onStop() call finish() so that ImportVCardActivity does not show ugly behavior
authorDaisuke Miyakawa <dmiyakawa@google.com>
Tue, 22 Sep 2009 03:28:16 +0000 (20:28 -0700)
committerDaisuke Miyakawa <dmiyakawa@google.com>
Tue, 22 Sep 2009 03:38:22 +0000 (20:38 -0700)
when a user changes the device's orientation (by sliding hardware keyboard, etc.).

Internal issue number: 2136137

src/com/android/contacts/ImportVCardActivity.java

index a3d5de5..4b59e16 100644 (file)
@@ -789,7 +789,21 @@ public class ImportVCardActivity extends Activity {
         super.onStop();
         if (mVCardReadThread != null) {
             // The Activity is no longer visible. Stop the thread.
-            // TODO: The Activity may be destroyed without this method being called.
+            mVCardReadThread.cancel();
+            mVCardReadThread = null;
+        }
+
+        // ImportVCardActivity should not be persistent. In other words, if there's some
+        // event calling onStop(), this Activity should finish its work and give the main
+        // screen back to the caller Activity.
+        finish();
+    }
+
+    @Override
+    public void finalize() {
+        if (mVCardReadThread != null) {
+            // Not sure this procedure is really needed, but just in case...
+            Log.w(LOG_TAG, "VCardReadThread exists while this Activity is now being killed!");
             mVCardReadThread.cancel();
             mVCardReadThread = null;
         }