If I physically slide out the keyboard on my Moto Droid A855, it crashes my test app with the stack trace pasted below. I don\'t understand why?
Also, if I start my
yeah I don't see this bug before.. but then again I have this in my manifest
<activity
android:name=".MainActivity"
android:configChanges="keyboardHidden|navigation"
android:label="@string/app_name"
android:launchMode="singleTop" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
I know this question was asked almost two years ago, but since then a very easy fix has been implemented. Just add android:configChanges="orientation|keyboard|keyboardHidden"
into each Activity call in the Manifest.
It's really difficult to help you if you don't provide some part of your code... anyway, this error is not new and there are some workarounds in order to solve it (I guess is some bug)... try to do this:
@Override
protected void onDetachedFromWindow() {
try {
super.onDetachedFromWindow();
}
catch (IllegalArgumentException e) {
stopFlipping();
}
}
This is for overriding the onDetachedFromWindow
and I hope it works for you.
To resolve this issue you must
MyViewFlipper
which overrides ViewFlipper
(see below)ViewFlipper
New class called MyViewFlipper
. Contains the following:
package com.gtosoft.dash; // change this to match your own app.
import android.content.Context;
import android.util.AttributeSet;
import android.util.Log;
import android.widget.ViewFlipper;
public class MyViewFlipper extends ViewFlipper {
public MyViewFlipper(Context context, AttributeSet attrs) {
super(context, attrs);
}
@Override
protected void onDetachedFromWindow() {
try{
super.onDetachedFromWindow();
}catch(Exception e) {
Log.d("MyViewFlipper","Stopped a viewflipper crash");
stopFlipping();
}
}
}
Now to use this "fixed" version of ViewFlipper
you have to reference it in the xml layout. Since it is basically a "custom view", you have to fully qualify the package path to MyViewFlipper
, as seen here:
<com.gtosoft.dash.MyViewFlipper
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/vFlipper"
android:layout_width="wrap_content"
android:layout_height="wrap_content">
(insert all the other old layout code here)
</com.gtosoft.dash.MyViewFlipper>
Now the app no longer crashes on the keyboard slide event or if the app is started with slide already out. Look for this in the log:
06-11 20:08:15.811 D/MyViewFlipper( 6106): Stopped a viewflipper crash
Credit: http://code.google.com/p/android/issues/detail?id=6191