Android emulator rotates but application does not redraw

I saw photos of this elsewhere, but from some time ago, where the answer is generally "this is a known issue with Android 2.3," I use 4.4, so definitely not the answer.

I have about the simplest program: "Hello, Android." When I run the emulator, it loads in portrait mode. Using Fn-Ctrl-F11 (Mac), the emulator rotates to landscape mode. But the application and phone controls are not redrawn - all this 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 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 am building with Eclipse the ADT build v22.3.0-887826 assembly, although I cannot imagine that this is important for something so trivial.

Galaxy Nexus, Android 4.4 API 19. , . " ", - 3/12 .

Android, . TIA , .

EDIT: 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;
}

}
+4
2

-, : 4.4

" , ".

, ; OTOH google... , ? , ? , .

:

: CommonsWare, Framework Android.

android 4.4

+2

, Activity lifecycle.

Log Toast, , .

:

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();
}


}

, !

+2

All Articles