0

So there are lots of SO posts on this topic but neither working in my case.

Orientation is not calling any method of activity.

I tried all possible ways mentioned like:

Putting android:configChanges="orientation|keyboardHidden|screenSize" in the calling activity.

Then putting onConfigurationChanged method as:

@Override
    public void onConfigurationChanged(Configuration conf) {
        super.onConfigurationChanged(conf);
        System.out.println("on onConfigurationChanged called..............");
    }

But its not getting called.

onCreate(), onResume(), onRestoreInstanceState() methods are also not getting called when I do change the screen orientation.

Further, I changed the sdk versions and target versions but without success.

UPDATE:

My part of activity from manifest from activity is:

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.wassap.main"
    android:versionCode="1"
    android:versionName="1.0" >

  <uses-sdk
    android:minSdkVersion="8"
    android:targetSdkVersion="16"/>

        <activity
            android:name=".UserActivity"
            android:label="@string/app_name"
             android:launchMode="singleTask"
             android:configChanges="orientation|keyboardHidden|screenSize" >
        </activity>

Relevant UserActivity XML-

           <LinearLayout
             android:layout_width="fill_parent"
             android:layout_height="fill_parent"
             android:orientation="horizontal"
             android:clickable="true"                
             android:onClick="buildDocument">

           <TextView
             android:id="@+id/title"
             android:layout_width="wrap_content"
             android:layout_height="wrap_content"
             android:text="Build Document">
           </TextView>
        </LinearLayout>

UserActivity class is the class in which I do orientation after onClick buildDocument.

When I am in UserActivity, probably by a click of buildDocument, I also noticed that destroy() method is also not called when I go back clicking on back button.

All in all, no life cycle method seems to be getting called.

sjain
  • 23,126
  • 28
  • 107
  • 185
  • I think this has been resolved in here. http://stackoverflow.com/questions/5620033/onconfigurationchanged-not-getting-called – MrCurious May 02 '13 at 15:18
  • Is this on emulator or real device? – codeMagic May 02 '13 at 15:18
  • @codeMagic this is in real device attached via cable to my laptop running code to test. – sjain May 02 '13 at 15:20
  • are you relying on the Log to understand if onConfigurationChanged is being called or not? – Blackbelt May 02 '13 at 15:24
  • 1
    Could you please post the entire activity code? At least the first lines where you define your class and variables – edoardotognoni May 02 '13 at 15:25
  • @blackbelt yes of-course, I am not getting desired log when I change my orientation. Isn't it work that way? – sjain May 02 '13 at 15:27
  • Tipically yes it does. Can you try using the debugger and check it a brekpoint is hitted? – Blackbelt May 02 '13 at 15:28
  • my none of the breakpoint works when I change the orientation. I placed them in onCreate(), onResume(), onConfigurationChanged() but nothing worked. – sjain May 02 '13 at 15:40
  • @edoardotognoni My class contains around 1800 lines of code. All method implementations are normal as we do override activity methods. – sjain May 02 '13 at 15:41
  • Please post the part of the manifest for the activity in question – David Wasser May 02 '13 at 16:27
  • @DavidWasser Posted in the question. – sjain May 03 '13 at 07:53
  • Remove 'android:configChanges="orientation|keyboardHidden|screenSize"' from your manifest. That line tells the android that your app will handle all of those configuration changes. So the system does not try to handle them by itself. – Larry McKenzie May 03 '13 at 08:19
  • Also your launch mode could be causing some of your other activity life cycle issues. – Larry McKenzie May 03 '13 at 08:22
  • My bad..there was a call to some other activity down the number of lines after build document click causing this User activity to be left out. I put logger in that other activity and all went fine. Thanks! – sjain May 03 '13 at 08:31
  • Then please answer your own question (or delete it) so that it doesn't end up in the unanswered questions list. – David Wasser May 03 '13 at 12:05

1 Answers1

0

Finally got it right. There was a call to some other activity inside the user activity that started it and so the current activity is not the concerned one to be taken into account for orientation. In the other activity, I added logger to check the orientation change and its working fine.

sjain
  • 23,126
  • 28
  • 107
  • 185