Questions tagged [fragment-lifecycle]

Covers how and when the lifecycle callback methods like onAttach, onCreateView etc. are being called when the fragment is created, destroyed, recreated or put in the backStack.

150 questions
0
votes
3 answers

Fragments get re-created upon bottomnavigationview change item click

I have an activity with a Framelayout and a BottomNavigationView...I have 4 fragments (A,B,C,D)...The thing is when I switch from A to B after clicking on the menu item to load fragment B, fragment A gets destroyed...I added a Log message on all the…
0
votes
1 answer

how to refresh the edittext after the alertdialog is closed

I want to change the values of the 3 edittexts after the user presses confirm in the alertdialog.But it is not refreshing.the values are only changing after moving to some other fragment and coming back to this fragment SharedPreferences…
0
votes
0 answers

AppCompatActivity onDestroy calls Fragment's onCreateView?

In my app I have the MainActivity containing two fragments that are tabbed. Somehow I get an exception that is evolving from the MainActivity's onDestroy that is eventually calling fragment's onCreateView. I am aware that in the fragment's lifecycle…
0
votes
0 answers

Android onCreateOptionsMenu called twice when the orientation changes

I'm playing with the Android lifecycle and I found a behavior that seems to have been poorly documented (or I'm just doing something wrong). The onCreateOptionsMenu method, as specified at…
0
votes
1 answer

Saving states of multiple fragments in activity

I am working on an application and there is one specific thing that is bothering me. Let's just say I have one activity and 2 fragments.FragmentA and FragmentB and FragmentA gets attached when activity starts. I want to save the fragment data and…
Umair
  • 6,366
  • 15
  • 42
  • 50
0
votes
2 answers

How can I change the android code to make it work again?

I am a android beginner who follows a book.now I have a problem.the test app is an news app and have code like this: public class NewsTitleFragment extends Fragment implements OnItemClickListener { private ListView newsTitleListView; private…
cramile
  • 13
  • 2
0
votes
2 answers

Android Activities Lifecylcle Methods implementation

I have Build a Simple app with a Home Activity and an Activity Drawer and some fragment tabs, What i could not understand is how to make the app resume from the last activity or the fragment since the user clicked the return button on his phone ! I…
0
votes
1 answer

Fragment crashing when rotate screen or minimise theapplication

I am going from 1st fragment to 2nd. The application crashes when i rotate or minimise the screen on the 2nd fragment. Earlier when i used to minimise the app 1st fragment was being called (don't know why), now its crashing here is the code : 2nd…
0
votes
1 answer

Is the Bundle passed on onCreate to Activity and Child Fragment different?

Is private copy ofBundle is passed to Fragment and the parent Activity? I try to save key,value pair in onSaveInstanceState of Fragment and try to retrieve it in the onCreate of Activity. It is absent there. But there also seems to be a connection…
0
votes
1 answer

Android kill a service on fragment replace (lifecycle of replace fragment)

In my app I use a mediaplayer service. When I call a replace fragment I want to kill that service. Looking at the answers on Stackoverflow and Androids site I have not seen a straight answer. What parts of the fragment lifecycle are called once a…
0
votes
1 answer

Is it correct to tie GoogleApiClient to Fragment lifecycle

After using startResolutionForResult, onActivityResult method will be called within the Activity owning the Fragment, not within the Fragment itself. Also this answer says: The Google Play game services API should be tied to an Activity's …
osrl
  • 8,168
  • 8
  • 36
  • 57
0
votes
0 answers

Playing video in TextureView crash when resuming from onPause

If I pause my activity, on returning I get a crash Caused by: java.lang.IllegalStateException at android.media.MediaPlayer.prepareAsync(Native Method) I want to be able to return to exactly where the video left off and continue from there. I also…
learner
  • 11,490
  • 26
  • 97
  • 169
0
votes
0 answers

Fragment Master-Details with saved State

In an activity there is a fragment that contains a list of objects. This fragment should be replaced by another fragment that contains details of a list item. When the detail fragment is active and the back button is pressed then the listfragment…
Anthea
  • 3,741
  • 5
  • 40
  • 64
0
votes
2 answers

Does onCreate() called after commit()?

private class DrawerItemClickListener implements ListView.OnItemClickListener { @Override public void onItemClick(AdapterView parent, View view, int position, long id) { selectItem(position); } } private…
thirtvanke
  • 39
  • 2
  • 5
0
votes
0 answers

How to auto start function Fragment Life cycle

I have an application in which I am attaching different fragment with activity. and in that activity container I am replacing different fragment. So at the start of the activity I replace the MapFragment in the activity container. Later on I…
Coas Mckey
  • 701
  • 1
  • 13
  • 39
1 2 3
9
10