I'm encountering a peculiar issue with the user of FragmentActivity.

In my test app, my FragmentActivity's onCreate method calls
setContentView, which inflates a simple layout consisting of a single
Fragment.

However, I'm finding that when the device is rotated, this process
causes additional Fragments to be created, such that after one
rotation there are two Fragment instances, and after two rotations
there are three Fragment instances being created.

I'm also unclear why, when this Activity is first launched, the
Fragment instance created via setContentView() appears to be started,
stopped, and then started again.

Below is a logcat demonstrating the issue (hashCodes in brackets).
Should fragments simply not be inflated via setContentView?

*** App launched ***
05-22 17:39:13.044: VERBOSE/DupeFrag(10519):
TestActivity(1080185976).onStart()
05-22 17:39:13.044: VERBOSE/DupeFrag(10519):
TestFragment(1080196160).onStart()
05-22 17:39:13.044: VERBOSE/DupeFrag(10519):
TestFragment(1080196160).onStop()
05-22 17:39:13.044: VERBOSE/DupeFrag(10519):
TestFragment(1080196160).onStart()
*** Device rotated (1) ***
05-22 17:39:17.779: VERBOSE/DupeFrag(10519):
TestActivity(1080185976).onStop()
05-22 17:39:17.779: VERBOSE/DupeFrag(10519):
TestFragment(1080196160).onStop()
05-22 17:39:17.799: VERBOSE/DupeFrag(10519):
TestActivity(1080209384).onStart()
05-22 17:39:17.799: VERBOSE/DupeFrag(10519):
TestFragment(1080211584).onStart()
05-22 17:39:17.799: VERBOSE/DupeFrag(10519):
TestFragment(1080223880).onStart()
05-22 17:39:17.799: VERBOSE/DupeFrag(10519):
TestFragment(1080211584).onStop()
05-22 17:39:17.799: VERBOSE/DupeFrag(10519):
TestFragment(1080223880).onStop()
05-22 17:39:17.799: VERBOSE/DupeFrag(10519):
TestFragment(1080211584).onStart()
05-22 17:39:17.799: VERBOSE/DupeFrag(10519):
TestFragment(1080223880).onStart()
*** Device rotated (2) ***
05-22 17:39:19.500: VERBOSE/DupeFrag(10519):
TestActivity(1080209384).onStop()
05-22 17:39:19.500: VERBOSE/DupeFrag(10519):
TestFragment(1080211584).onStop()
05-22 17:39:19.500: VERBOSE/DupeFrag(10519):
TestFragment(1080223880).onStop()
05-22 17:39:19.520: VERBOSE/DupeFrag(10519):
TestActivity(1080235792).onStart()
05-22 17:39:19.520: VERBOSE/DupeFrag(10519):
TestFragment(1080238000).onStart()
05-22 17:39:19.520: VERBOSE/DupeFrag(10519):
TestFragment(1080238336).onStart()
05-22 17:39:19.520: VERBOSE/DupeFrag(10519):
TestFragment(1080252384).onStart()
05-22 17:39:19.520: VERBOSE/DupeFrag(10519):
TestFragment(1080238000).onStop()
05-22 17:39:19.520: VERBOSE/DupeFrag(10519):
TestFragment(1080238336).onStop()
05-22 17:39:19.520: VERBOSE/DupeFrag(10519):
TestFragment(1080252384).onStop()
05-22 17:39:19.520: VERBOSE/DupeFrag(10519):
TestFragment(1080238000).onStart()
05-22 17:39:19.520: VERBOSE/DupeFrag(10519):
TestFragment(1080238336).onStart()
05-22 17:39:19.520: VERBOSE/DupeFrag(10519):
TestFragment(1080252384).onStart()

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to