I created a Hello World app and added Landscape version of the xml. In portrait mode I have NO TextView but in Landscape version I added a TextView. I do a findviewbyid in java for this textView In Manifest I set the screen orientation to be landscape.
First time when I launch app: no problem. Now I press Power Off and then Power ON button and app crashes with NullPointer exception that textView is not found.
How do I make sure that app load fine in landscape mode directly without looking for resources in portrait mode?
Manifest:
<activity android:name=".MainActivity"
android:screenOrientation="landscape">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
Activity:
TextView tv;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
tv = (TextView)findViewById(R.id.tv);
tv.setText("inLandscape");
}