Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android - end fragment activity [duplicate]

Tags:

android

What is the equivalent of

finish() 

for a fragment activity in

OnPause();

I cant find it anywhere, I just want the fragment to end when it is paused

like image 754
user222786 Avatar asked Jun 18 '13 22:06

user222786


2 Answers

As others have already stated, call finish() as you would in a regular Activity. In regards to the onPause() part of your question, I'm not sure what you are looking for, but it might be a good idea to review the lifecycles of Activities and Fragments...

Activity Lifecycle

enter image description here

http://developer.android.com/reference/android/app/Activity.html#ActivityLifecycle

Fragment Lifecycle

enter image description here

http://developer.android.com/reference/android/app/Fragment.html#Lifecycle

like image 105
invertigo Avatar answered Sep 30 '22 15:09

invertigo


call this line and it will kill the current fragment

getActivity().finish();
like image 38
Nitin Avatar answered Sep 30 '22 15:09

Nitin