From b9740e3f144bc211b9e281448843e810d93a6327 Mon Sep 17 00:00:00 2001 From: Lalitha S Oruganty <32945884+lorugant@users.noreply.github.com> Date: Wed, 25 Apr 2018 18:08:46 -0400 Subject: [PATCH] fix press back button in cmd exit the app (#93) --- app/src/main/java/io/treehouses/remote/Dashboard.java | 3 +++ 1 file changed, 3 insertions(+) diff --git a/app/src/main/java/io/treehouses/remote/Dashboard.java b/app/src/main/java/io/treehouses/remote/Dashboard.java index 14ff239be..8e73d394b 100644 --- a/app/src/main/java/io/treehouses/remote/Dashboard.java +++ b/app/src/main/java/io/treehouses/remote/Dashboard.java @@ -40,6 +40,7 @@ public class Dashboard extends Fragment { private static final String TAG = "BluetoothChatFragment"; + private static final String BACK_STACK_ROOT_TAG = "root_fragment"; //current connection status @@ -103,9 +104,11 @@ public void onClick(View view) { @Override public void onClick(View view) { FragmentManager fragmentManager = getFragmentManager(); + fragmentManager.popBackStack(BACK_STACK_ROOT_TAG, FragmentManager.POP_BACK_STACK_INCLUSIVE); android.support.v4.app.FragmentTransaction fragmentTransaction = fragmentManager.beginTransaction(); BluetoothChatFragment chatfrag = new BluetoothChatFragment(); fragmentTransaction.replace(R.id.sample_layout,chatfrag); + fragmentTransaction.addToBackStack(BACK_STACK_ROOT_TAG); fragmentTransaction.commit(); } });