0

In my onCreate method I have a call to handleIntent which is responsible for handling intents. Inside that call (among other things) I create fragment.

This causes that fragment to be created twice on orientation change (one which was previously created on activity start, restored from FragmentManager, other again created in handleIntent method that is called because onCreate method is called when orientation changes).

What is the proper way to avoid that - that is how to avoid handleIntent being called on orientation change?

zduny
  • 2,481
  • 1
  • 27
  • 49

2 Answers2

0

Add this to your manifest:

<activity android:name=".MyActivity" 
      android:configChanges="orientation|keyboardHidden" /> 

Now, the onConfigurationChanged method will be called instead of onCreate, and you can override that to make whatever changes it is that you want.

RogueBaneling
  • 4,331
  • 4
  • 22
  • 33
0

By default, android will re-create the activity when the orientation changes. So you are actually getting onCreate called when the orientation changes.

Take a look at these questions if you want more control handling orientation changes:

Activity restart on rotation Android

How do I disable orientation change on Android?

Community
  • 1
  • 1
swbandit
  • 1,986
  • 1
  • 26
  • 37