I have tried to build a test application that merely relays a toast message when configuration changes happen. (well thats what its suppose to do, it doesn't work) The purpose in the end is to detect if the user places the tablet into a keyboard cradle or removes it from one. my manifest and main activity are below.. I thought this code would fire a toast when ever the tablet has a configuration change to the uiMode or external keyboard.. but nothing is happening when i dock/undock it.. please help
my manifest:
<?xml version="1.0" encoding="utf-8"?>
<uses-sdk android:minSdkVersion="12" />
<application
android:icon="@drawable/ic_launcher"
android:label="@string/app_name" >
<activity
android:name=".UiModeTestActivity"
android:configChanges="keyboard|uiMode"
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>
my java:
package com.eliddell;
import android.app.Activity;
import android.content.res.Configuration;
import android.os.Bundle;
import android.widget.Toast;
public class UiModeTestActivity extends Activity {
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
}
@Override
public void onConfigurationChanged(Configuration newConfig) {
super.onConfigurationChanged(newConfig);
Toast.makeText(getApplicationContext(), "new config:"+newConfig, Toast.LENGTH_LONG).show();
}
}