diff --git a/src/com/android/dialer/DialtactsActivity.java b/src/com/android/dialer/DialtactsActivity.java
index 726c176..61fab17 100644
--- a/src/com/android/dialer/DialtactsActivity.java
+++ b/src/com/android/dialer/DialtactsActivity.java
@@ -71,9 +71,9 @@
 import com.android.dialer.dialpad.DialpadFragment;
 import com.android.dialer.dialpad.SmartDialNameMatcher;
 import com.android.dialer.interactions.PhoneNumberInteraction;
+import com.android.dialer.list.AllContactsActivity;
 import com.android.dialer.list.PhoneFavoriteFragment;
 import com.android.dialer.list.OnListFragmentScrolledListener;
-import com.android.dialer.list.ShowAllContactsFragment;
 import com.android.dialer.list.SmartDialSearchFragment;
 import com.android.internal.telephony.ITelephony;
 
@@ -89,7 +89,8 @@
         DialpadFragment.OnDialpadQueryChangedListener, PopupMenu.OnMenuItemClickListener,
         OnListFragmentScrolledListener,
         PhoneFavoriteFragment.OnPhoneFavoriteFragmentStartedListener,
-        DialpadFragment.OnDialpadFragmentStartedListener {
+        DialpadFragment.OnDialpadFragmentStartedListener,
+        PhoneFavoriteFragment.OnShowAllContactsListener {
     private static final String TAG = "DialtactsActivity";
 
     public static final boolean DEBUG = false;
@@ -141,8 +142,6 @@
      */
     private SmartDialSearchFragment mSmartDialSearchFragment;
 
-    private ShowAllContactsFragment mShowAllContactsFragment;
-
     private View mMenuButton;
     private View mCallHistoryButton;
     private View mDialpadButton;
@@ -257,16 +256,12 @@
             mRegularSearchFragment = new SearchFragment();
             mSmartDialSearchFragment = new SmartDialSearchFragment();
             mDialpadFragment = new DialpadFragment();
-            mShowAllContactsFragment = new ShowAllContactsFragment();
-            mShowAllContactsFragment.setOnPhoneNumberPickerActionListener(
-                    mPhoneNumberPickerActionListener);
 
             // TODO krelease: load fragments on demand instead of creating all of them at run time
             final FragmentTransaction ft = getFragmentManager().beginTransaction();
             ft.add(R.id.dialtacts_frame, mPhoneFavoriteFragment, TAG_FAVORITES_FRAGMENT);
             ft.add(R.id.dialtacts_frame, mRegularSearchFragment, TAG_REGULAR_SEARCH_FRAGMENT);
             ft.add(R.id.dialtacts_frame, mSmartDialSearchFragment, TAG_SMARTDIAL_SEARCH_FRAGMENT);
-            ft.add(R.id.dialtacts_frame, mShowAllContactsFragment, TAG_SHOW_ALL_CONTACTS_FRAGMENT);
             ft.add(R.id.dialtacts_container, mDialpadFragment, TAG_DIALPAD_FRAGMENT);
             ft.commit();
         }
@@ -298,11 +293,6 @@
         mSmartDialSearchFragment.setOnPhoneNumberPickerActionListener(
                 mPhoneNumberPickerActionListener);
 
-        mShowAllContactsFragment = (ShowAllContactsFragment) fm.findFragmentByTag(
-                TAG_SHOW_ALL_CONTACTS_FRAGMENT);
-        mShowAllContactsFragment.setOnPhoneNumberPickerActionListener(
-                mPhoneNumberPickerActionListener);
-
         if (mFirstLaunch) {
             displayFragment(getIntent());
         }
@@ -312,8 +302,7 @@
     @Override
     public void onAttachFragment(Fragment fragment) {
         if (fragment instanceof DialpadFragment || fragment instanceof SearchFragment
-                || fragment instanceof SmartDialSearchFragment
-                || fragment instanceof ShowAllContactsFragment) {
+                || fragment instanceof SmartDialSearchFragment) {
             final FragmentTransaction transaction = getFragmentManager().beginTransaction();
             transaction.hide(fragment);
             transaction.commit();
@@ -323,16 +312,6 @@
     }
 
     @Override
-    public boolean onOptionsItemSelected(MenuItem item) {
-        switch (item.getItemId()) {
-            // Respond to the action bar's Up/Home button
-            case android.R.id.home:
-                hideAllContactsFragment();
-        }
-        return super.onOptionsItemSelected(item);
-    }
-
-    @Override
     public boolean onMenuItemClick(MenuItem item) {
         switch (item.getItemId()) {
             case R.id.menu_import_export:
@@ -439,23 +418,6 @@
         ft.commit();
     }
 
-    public void showAllContactsFragment() {
-        final FragmentTransaction ft = getFragmentManager().beginTransaction();
-        ft.hide(mPhoneFavoriteFragment);
-        ft.show(mShowAllContactsFragment);
-        // TODO{klp} Add animation
-        ft.commit();
-        hideSearchBar(false);
-    }
-
-    private void hideAllContactsFragment() {
-        final FragmentTransaction ft = getFragmentManager().beginTransaction();
-        ft.hide(mShowAllContactsFragment);
-        ft.show(mPhoneFavoriteFragment);
-        ft.commit();
-        showSearchBar();
-    }
-
     private void prepareSearchView() {
         mSearchViewContainer = findViewById(R.id.search_view_container);
         mSearchViewCloseButton = findViewById(R.id.search_close_button);
@@ -801,8 +763,6 @@
             hideDialpadFragment(true);
         } else if (mInSearchUi) {
             mSearchView.setText(null);
-        } else if (mShowAllContactsFragment.isVisible()) {
-            hideAllContactsFragment();
         } else if (isTaskRoot()) {
             // Instead of stopping, simply push this to the back of the stack.
             // This is only done when running at the top of the stack;
@@ -846,4 +806,10 @@
                 Context.TELEPHONY_SERVICE);
         return tm.getCallState() != TelephonyManager.CALL_STATE_IDLE;
     }
+
+    @Override
+    public void onShowAllContacts() {
+        final Intent intent = new Intent(this, AllContactsActivity.class);
+        startActivity(intent);
+    }
 }
diff --git a/src/com/android/dialer/list/AllContactsActivity.java b/src/com/android/dialer/list/AllContactsActivity.java
new file mode 100644
index 0000000..c46702f
--- /dev/null
+++ b/src/com/android/dialer/list/AllContactsActivity.java
@@ -0,0 +1,100 @@
+/*
+ * Copyright (C) 2013 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.android.dialer.list;
+
+import android.app.ActionBar;
+import android.app.Fragment;
+import android.content.Intent;
+import android.net.Uri;
+import android.os.Bundle;
+import android.text.Spannable;
+import android.text.SpannableString;
+import android.text.style.TypefaceSpan;
+import android.util.Log;
+
+import com.android.contacts.common.CallUtil;
+import com.android.contacts.common.activity.TransactionSafeActivity;
+import com.android.contacts.common.list.OnPhoneNumberPickerActionListener;
+import com.android.dialer.DialtactsActivity;
+import com.android.dialer.R;
+import com.android.dialer.interactions.PhoneNumberInteraction;
+
+public class AllContactsActivity extends TransactionSafeActivity {
+    private static final String TAG = AllContactsActivity.class.getSimpleName();
+
+    private AllContactsFragment mAllContactsFragment;
+
+    // Same behavior as {@link DialtactsActivity}
+    private final OnPhoneNumberPickerActionListener mPhoneNumberPickerActionListener =
+            new OnPhoneNumberPickerActionListener() {
+                @Override
+                public void onPickPhoneNumberAction(Uri dataUri) {
+                    // Specify call-origin so that users will see the previous tab instead of
+                    // CallLog screen (search UI will be automatically exited).
+                    PhoneNumberInteraction.startInteractionForPhoneCall(
+                        AllContactsActivity.this, dataUri, null);
+                }
+
+                @Override
+                public void onCallNumberDirectly(String phoneNumber) {
+                final Intent intent = CallUtil.getCallIntent(phoneNumber, null);
+                    startActivity(intent);
+                }
+
+                @Override
+                public void onShortcutIntentCreated(Intent intent) {
+                    Log.w(TAG, "Unsupported intent has come (" + intent + "). Ignoring.");
+                }
+
+                @Override
+                public void onHomeInActionBarSelected() {
+                    // {@link PhoneNumberPickerFragment handles onClick on the home button
+                    // and performs the callback here. This means we don't have to handle it
+                    // ourself in the activity.
+                    final Intent intent = new Intent(AllContactsActivity.this,
+                            DialtactsActivity.class);
+                    intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
+                    startActivity(intent);
+                }
+    };
+
+    @Override
+    protected void onCreate(Bundle savedInstanceState) {
+        super.onCreate(savedInstanceState);
+
+        final ActionBar actionBar = getActionBar();
+        actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_STANDARD);
+        actionBar.setDisplayShowHomeEnabled(true);
+        actionBar.setDisplayHomeAsUpEnabled(true);
+        actionBar.setDisplayShowTitleEnabled(true);
+
+        final SpannableString s = new SpannableString(getString(R.string.show_all_contacts_title));
+        s.setSpan(new TypefaceSpan(getString(R.string.show_all_contacts_title_font_family)), 0,
+                s.length(), Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
+        actionBar.setTitle(s);
+
+        setContentView(R.layout.all_contacts_activity);
+    }
+
+    @Override
+    public void onAttachFragment(Fragment fragment) {
+        if (fragment instanceof AllContactsFragment) {
+            mAllContactsFragment = (AllContactsFragment) fragment;
+            mAllContactsFragment.setOnPhoneNumberPickerActionListener(
+                    mPhoneNumberPickerActionListener);
+        }
+    }
+}
diff --git a/src/com/android/dialer/list/AllContactsFragment.java b/src/com/android/dialer/list/AllContactsFragment.java
new file mode 100644
index 0000000..40d5c14
--- /dev/null
+++ b/src/com/android/dialer/list/AllContactsFragment.java
@@ -0,0 +1,55 @@
+/*
+
+ * Copyright (C) 2013 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.dialer.list;
+
+import android.app.Activity;
+import android.os.Bundle;
+import android.view.LayoutInflater;
+import android.view.View;
+import android.view.ViewGroup;
+
+import com.android.contacts.common.list.ContactListItemView;
+import com.android.contacts.common.list.PhoneNumberPickerFragment;
+import com.android.dialer.R;
+
+/**
+ * Fragments to show all contacts with phone numbers.
+ */
+public class AllContactsFragment extends PhoneNumberPickerFragment{
+
+    @Override
+    public void onCreate(Bundle savedInstanceState) {
+        super.onCreate(savedInstanceState);
+    }
+
+    @Override
+    public void onAttach(Activity activity) {
+        super.onAttach(activity);
+
+        // Customizes the listview according to the dialer specifics.
+        setQuickContactEnabled(true);
+        setDarkTheme(false);
+        setPhotoPosition(ContactListItemView.getDefaultPhotoPosition(true /* opposite */));
+        setUseCallableUri(true);
+    }
+
+    @Override
+    protected View inflateView(LayoutInflater inflater, ViewGroup container) {
+        return inflater.inflate(R.layout.show_all_contacts_fragment, null);
+    }
+}
diff --git a/src/com/android/dialer/list/PhoneFavoriteFragment.java b/src/com/android/dialer/list/PhoneFavoriteFragment.java
index 64a9b84..589a7b1 100644
--- a/src/com/android/dialer/list/PhoneFavoriteFragment.java
+++ b/src/com/android/dialer/list/PhoneFavoriteFragment.java
@@ -19,6 +19,7 @@
 import android.app.Fragment;
 import android.app.LoaderManager;
 import android.content.CursorLoader;
+import android.content.Intent;
 import android.content.Loader;
 import android.database.Cursor;
 import android.graphics.Rect;
@@ -70,6 +71,10 @@
         public void onPhoneFavoriteFragmentStarted();
     }
 
+    public interface OnShowAllContactsListener {
+        public void onShowAllContacts();
+    }
+
     public interface Listener {
         public void onContactSelected(Uri contactUri);
         public void onCallNumberDirectly(String phoneNumber);
@@ -133,9 +138,9 @@
     private Listener mListener;
 
     private OnListFragmentScrolledListener mActivityScrollListener;
+    private OnShowAllContactsListener mShowAllContactsListener;
     private PhoneFavoriteMergedAdapter mAdapter;
     private PhoneFavoritesTileAdapter mContactTileAdapter;
-    private PhoneNumberListAdapter mAllContactsAdapter;
 
     private CallLogAdapter mCallLogAdapter;
     private CallLogQueryHandler mCallLogQueryHandler;
@@ -286,6 +291,13 @@
                     + " must implement OnListFragmentScrolledListener");
         }
 
+        try {
+            mShowAllContactsListener = (OnShowAllContactsListener) activity;
+        } catch (ClassCastException e) {
+            throw new ClassCastException(activity.toString()
+                    + " must implement OnShowAllContactsListener");
+        }
+
         // Use initLoader() instead of restartLoader() to refraining unnecessary reload.
         // This method call implicitly assures ContactTileLoaderListener's onLoadFinished() will
         // be called, on which we'll check if "all" contacts should be reloaded again or not.
@@ -311,10 +323,7 @@
      * Gets called when user click on the show all contacts button.
      */
     private void showAllContacts() {
-        // TODO {klp} Use interface for the fragment to communicate with the activity
-        if (getActivity() instanceof  DialtactsActivity) {
-            ((DialtactsActivity) getActivity()).showAllContactsFragment();
-        }
+        mShowAllContactsListener.onShowAllContacts();
     }
 
     public void setListener(Listener listener) {
diff --git a/src/com/android/dialer/list/ShowAllContactsFragment.java b/src/com/android/dialer/list/ShowAllContactsFragment.java
deleted file mode 100644
index 85806b6..0000000
--- a/src/com/android/dialer/list/ShowAllContactsFragment.java
+++ /dev/null
@@ -1,89 +0,0 @@
-/*
-
- * Copyright (C) 2013 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.dialer.list;
-
-import android.app.ActionBar;
-import android.app.Activity;
-import android.os.Bundle;
-import android.text.Spannable;
-import android.text.SpannableString;
-import android.text.style.TypefaceSpan;
-import android.view.LayoutInflater;
-import android.view.View;
-import android.view.ViewGroup;
-
-import com.android.contacts.common.list.ContactListItemView;
-import com.android.contacts.common.list.PhoneNumberPickerFragment;
-import com.android.dialer.R;
-
-// TODO{klp}: Wrap this fragment with an activity.
-/**
- * Fragments to show all contacts with phone numbers.
- */
-public class ShowAllContactsFragment extends PhoneNumberPickerFragment{
-
-    @Override
-    public void onCreate(Bundle savedInstanceState) {
-        super.onCreate(savedInstanceState);
-    }
-
-    @Override
-    public void onAttach(Activity activity) {
-        super.onAttach(activity);
-
-        // Customizes the listview according to the dialer specifics.
-        setQuickContactEnabled(true);
-        setDarkTheme(false);
-        setPhotoPosition(ContactListItemView.getDefaultPhotoPosition(true /* opposite */));
-        setUseCallableUri(true);
-    }
-
-    @Override
-    public void onStart() {
-        // Displays action bar for quick navigation.
-        final ActionBar actionBar = getActivity().getActionBar();
-        actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_STANDARD);
-        actionBar.setDisplayShowHomeEnabled(true);
-        actionBar.setDisplayHomeAsUpEnabled(true);
-        actionBar.setDisplayShowTitleEnabled(true);
-
-        final SpannableString s = new SpannableString(getString(R.string.show_all_contacts_title));
-        s.setSpan(new TypefaceSpan(getString(R.string.show_all_contacts_title)), 0,
-                s.length(), Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
-        actionBar.setTitle(s);
-
-        super.onStart();
-    }
-
-    @Override
-    public void onHiddenChanged(boolean hidden) {
-        // Hides the action bar as it is hidden in the main activity
-        if (getActivity() != null) {
-            if (hidden) {
-                getActivity().getActionBar().hide();
-            } else {
-                getActivity().getActionBar().show();
-            }
-        }
-    }
-
-    @Override
-    protected View inflateView(LayoutInflater inflater, ViewGroup container) {
-        return inflater.inflate(R.layout.show_all_contacts_fragment, null);
-    }
-}
