Reputation: 693
I've seen pictures of this elsewhere, but from some time back where the answer is generally "this is a known issue with Android 2.3" I'm using 4.4, so that's definitely not the answer.
I have about the simplest program ever: "Hello, Android". When I launch the emulator, it load up in portrait mode. Using Fn-Ctrl-F11 (Mac), the emulator rotates to landscape mode. But the application and the phone controls do not redraw - the whole thing just looks sideways.
Here's the manifest:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.test.helloandroid"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="18"
android:targetSdkVersion="18" />
<application
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme" >
<activity
android:name="com.test.helloandroid.Hello"
android:label="@string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
and the Activity XML file:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".Hello" >
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/hello_world" />
</LinearLayout>
I'm building with Eclipse, the ADT bundle build v22.3.0-887826, although I can't imagine that matters for something this trivial.
My emulator is for device Galaxy Nexus, Android 4.4 API level 19. I've tried this with Hardware keyboard present marked and unmarked. I found reference to a "keyboard lid support" setting which I haven't seen anywhere - this comment is from 3/12 & so may be outdated.
This is my first Android app, so I'm a complete novice at debugging in this environment. TIA for any suggestions on what I'm missing.
EDIT: Adding code for hello.java
package com.test.helloandroid;
import android.os.Bundle;
import android.app.Activity;
import android.view.Menu;
public class Hello extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_hello);
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.hello, menu);
return true;
}
}
Upvotes: 4
Views: 2327
Reputation: 693
Apparently,everything old is new again: orientation change bug in 4.4
"The more they overthink the plumbing, the easier it is to stop up the drain."
It's good to know that I've not missed something obvious; OTOH this is a pretty obvious FAIL on the part of google's quality assurance... did bill gates sneak in there while no one was looking? Or are they greedy & trying to sell phones for testing by mucking up the emulators? Looks like there's a device in my future.
Edit :
Reference : Answered by CommonsWare,the Framework Engineer of Android.
Impossible to rotate the emulator with android 4.4
Upvotes: 2
Reputation: 15358
If you are beginner,you should go through this reference document to know about Activity lifecycle
.
Here,I'm including few Log
and Toast
to make it easier to understand the process happens when you rotate the screen.
Example:
package com.test.helloandroid;
import android.os.Bundle;
import android.app.Activity;
import android.view.Menu;
public class Hello extends Activity {
private static final String TAG = "Hello";
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_hello);
Log.d(TAG, "onCreate");
Toast.makeText(this, "onCreate", Toast.LENGTH_SHORT).show();
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.hello, menu);
return true;
}
@Override
protected void onResume() {
super.onResume();
Log.d(TAG, "onResume");
Toast.makeText(this, "onResume", Toast.LENGTH_SHORT).show();
}
@Override
protected void onPause() {
super.onPause();
Log.d(TAG, "onPause");
Toast.makeText(this, "onPause", Toast.LENGTH_SHORT).show();
}
}
I hope it will be helpful !!
Upvotes: 2