you can set this setting if a activity (or more than just one) should only run in a specific orientation.
Note that you need to have one entry for any activity you want it fixed.
SetActivityAttribute(servicemain, android:screenOrientation, "portrait")
SetActivityAttribute(Main, android:screenOrientation, "portrait")
SetActivityAttribute(Abnahme, android:screenOrientation, "portrait")
Upload a small project which shows the issue. Otherwise it is hard to help.
Make sure to load the activity layout not just when firsttime is true.