Android snippet activity - end

Which is equivalent

finish() 

for fragment activity in

 OnPause(); 

I can’t find it anywhere, I just want the fragment to end when it is paused

+6
source share
4 answers

As others have already pointed out, call finish (), as in normal activities. Regarding the onPause () part of your question, I'm not sure what you are looking for, but it might be a good idea to consider the life cycles of actions and fragments ...

Activity Life Cycle

enter image description here

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

Fragment Life Cycle

enter image description here

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

+10
source

call this line and it will kill the current fragment

 getActivity().finish(); 
+10
source

You can use the finish () function. FragmentActivity expands activity

http://developer.android.com/reference/android/support/v4/app/FragmentActivity.html

+1
source

A FragmentActivity expands from Activity , so you can use the finish() call to complete your class.

+1
source

Source: https://habr.com/ru/post/947604/


All Articles