0

i have three activities (A, B, C). This is my activity circle A => B, B => C, C => A when start activity C from activity B complete i don't call finish() function on B activity. when start A activity from C activity complete i all finish() function on C Activity. In A activity i implement back button to close application by use this code:

android.os.Process.killProcess(android.os.Process.myPid());

i want to close my app but the application restart B activity

Pham Hong Phong
  • 145
  • 2
  • 10
  • you are not supposed to do that. – njzk2 May 15 '13 at 09:09
  • I agree, Android will close your application when resources need to be freed, no need for killing your app. This is a old habit coming from older operating system. – L. G. May 15 '13 at 09:19

2 Answers2

0
android.os.Process.killProcess(android.os.Process.myPid()); 

Wont kill all the activity. you must use CLEAR_TOP flags in your intent. or you must use this method to finish ur B activity from C activity if needed. Another thing is use finish() Inside the onrestart overide method in your B activity.

Community
  • 1
  • 1
Jai Kumar
  • 920
  • 1
  • 7
  • 14
0

when you start A from C just add FLAG_ACTIVITY_CLEAR_TOP to your intent

Intent intent = new Intent(this, A.class);
intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
startActivity(intent);
Hoan Nguyen
  • 18,033
  • 3
  • 50
  • 54