6

i am making an application and i want to minimize the application when user click the minimize button and i am using the below code.below code minimize the Application but when i re open the application it always starts with the first activity.And i want the the application should resume from where the user has minimized the application.. i.e. user minimizes application when he is at 3rd activity and when he re open it the application should start with the 3rd activity not the 1st.

Intent main = new Intent(Intent.ACTION_MAIN);
        main.addCategory(Intent.CATEGORY_HOME);
        main.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
        startActivity(main);
MOBEEN Warar
  • 79
  • 1
  • 8
  • Look at http://developer.android.com/ – RaphMclee Sep 15 '13 at 19:26
  • You should probably let the user minimize the app through the home button. Anyways, you have to handle onResume() and onPause() methods of your activities to be sure it goes right back to where you want the app to be. Look for Activity lifecycle. – LuigiPower Sep 15 '13 at 19:32
  • 1
    What's all this talk of "minimise"? There is no such thing in Android. There is a *huge* difference between an app in the background in Android and a minimised app in a desktop OS. If you want to code Android apps, learn about the Activity stack and life cycle. I've commented because you mention a "minimise" button. – Simon Sep 15 '13 at 19:45

1 Answers1

19

Instead of your code try using

moveTaskToBack(true);

Read more about this function.

MaciejGórski
  • 22,187
  • 7
  • 70
  • 94