Search code examples
androidandroid-activityactivity-finish

How to close an activity from another activity


I need to close activity. But not right after its on pause. I need to close it when I'm in other activity.

how can I do that?


Solution

  • Try this method too,

    For Android Studio:

     ((Your Main Activity) Activity()).finish(); //this will close that corresponding activity 
    

    or

    android.os.Process.killProcess(android.os.Process.myPid()); //using this you can exit from the whole activity  for both Eclipse and Android studio
    

    For Eclipse:

      finish();
    

    Or

    private void kill_activity()
       { 
      finish();
      }