Merge "Changing search navigation in Contacts"
diff --git a/AndroidManifest.xml b/AndroidManifest.xml
index f44edf3..b7dc064 100644
--- a/AndroidManifest.xml
+++ b/AndroidManifest.xml
@@ -534,6 +534,7 @@
 
         <!-- vCard related -->
         <activity android:name=".vcard.ImportVCardActivity"
+            android:configChanges="orientation"
             android:theme="@style/BackgroundOnly">
             <intent-filter>
                 <action android:name="android.intent.action.VIEW" />
diff --git a/src/com/android/contacts/vcard/ImportVCardActivity.java b/src/com/android/contacts/vcard/ImportVCardActivity.java
index faa8bf3..01ff01a 100644
--- a/src/com/android/contacts/vcard/ImportVCardActivity.java
+++ b/src/com/android/contacts/vcard/ImportVCardActivity.java
@@ -16,6 +16,19 @@
 
 package com.android.contacts.vcard;
 
+import com.android.contacts.R;
+import com.android.contacts.model.AccountTypes;
+import com.android.contacts.util.AccountSelectionUtil;
+import com.android.vcard.VCardEntryCounter;
+import com.android.vcard.VCardInterpreterCollection;
+import com.android.vcard.VCardParser;
+import com.android.vcard.VCardParser_V21;
+import com.android.vcard.VCardParser_V30;
+import com.android.vcard.VCardSourceDetector;
+import com.android.vcard.exception.VCardException;
+import com.android.vcard.exception.VCardNestedException;
+import com.android.vcard.exception.VCardVersionException;
+
 import android.accounts.Account;
 import android.app.Activity;
 import android.app.AlertDialog;
@@ -25,10 +38,11 @@
 import android.content.ContentResolver;
 import android.content.Context;
 import android.content.DialogInterface;
-import android.content.Intent;
-import android.content.ServiceConnection;
 import android.content.DialogInterface.OnCancelListener;
 import android.content.DialogInterface.OnClickListener;
+import android.content.Intent;
+import android.content.ServiceConnection;
+import android.content.res.Configuration;
 import android.net.Uri;
 import android.os.Bundle;
 import android.os.Environment;
@@ -43,19 +57,6 @@
 import android.text.style.RelativeSizeSpan;
 import android.util.Log;
 
-import com.android.contacts.R;
-import com.android.contacts.model.AccountTypes;
-import com.android.contacts.util.AccountSelectionUtil;
-import com.android.vcard.VCardEntryCounter;
-import com.android.vcard.VCardInterpreterCollection;
-import com.android.vcard.VCardParser;
-import com.android.vcard.VCardParser_V21;
-import com.android.vcard.VCardParser_V30;
-import com.android.vcard.VCardSourceDetector;
-import com.android.vcard.exception.VCardException;
-import com.android.vcard.exception.VCardNestedException;
-import com.android.vcard.exception.VCardVersionException;
-
 import java.io.File;
 import java.io.IOException;
 import java.io.InputStream;
@@ -1009,17 +1010,17 @@
     }
 
     @Override
-    protected void onPause() {
-        super.onPause();
+    public void onConfigurationChanged(Configuration newConfig) {
+        super.onConfigurationChanged(newConfig);
+        // This Activity should finish itself on orientation change, and give the main screen back
+        // to the caller Activity.
+        finish();
+    }
 
+    @Override
+    protected void onDestroy() {
+        super.onDestroy();
         mConnection.tryDisconnectAndFinish();
-
-        // ImportVCardActivity should not be persistent. In other words, if there's some
-        // event calling onPause(), this Activity should finish its work and give the main
-        // screen back to the caller Activity.
-        if (!isFinishing()) {
-            finish();
-        }
     }
 
     /**
diff --git a/src/com/android/contacts/vcard/SelectAccountActivity.java b/src/com/android/contacts/vcard/SelectAccountActivity.java
index 3b78921..eb19673 100644
--- a/src/com/android/contacts/vcard/SelectAccountActivity.java
+++ b/src/com/android/contacts/vcard/SelectAccountActivity.java
@@ -61,6 +61,7 @@
         if (accountList.size() == 0) {
             Log.w(LOG_TAG, "Account does not exist");
             finish();
+            return;
         } else if (accountList.size() == 1) {
             final Account account = accountList.get(0);
             final Intent intent = new Intent();
@@ -68,6 +69,7 @@
             intent.putExtra(ACCOUNT_TYPE, account.type);
             setResult(RESULT_OK, intent);
             finish();
+            return;
         }
 
         // Multiple accounts. Let users to select one.