我有一个窗口弹出类,它在 aos 2.x(如 2.2.2、2.3.5 等)中运行良好,但在 aos 4.x 中崩溃。导致崩溃的代码如下:
public void dismissPopup(){
if (!isVisible)
return;
isVisible = false;
final Animation animation = AnimationUtils.loadAnimation(activity, R.anim.popup_hide);
animation.setAnimationListener(new AnimationListener() {
public void onAnimationEnd(final Animation animation) {
// The animation has ended
popupWindow.dismiss();
}
public void onAnimationRepeat(final Animation animation) {}
public void onAnimationStart(final Animation animation) {}
});
popupView.startAnimation(animation);
}
所以要让它在 aos 4.x 中工作,我必须注释所有的动画线,就像它有 2b 一样:
public void dismissPopup(){
if (!isVisible)
return;
isVisible = false;
popupWindow.dismiss();
}
这在 aos 4.1.x 中运行良好,但不提供动画。这里可能是什么问题?android 不应该提供任何 BACKWARD 兼容性吗?
崩溃日志
04-25 21:05:50.387: E/AndroidRuntime(8997): FATAL EXCEPTION: main
04-25 21:05:50.387: E/AndroidRuntime(8997): java.lang.NullPointerException
04-25 21:05:50.387: E/AndroidRuntime(8997): at android.view.ViewRootImpl.drawAccessibilityFocusedDrawableIfNeeded(ViewRootImpl.java:2301)
04-25 21:05:50.387: E/AndroidRuntime(8997): at android.view.ViewRootImpl.onHardwarePostDraw(ViewRootImpl.java:1931)
04-25 21:05:50.387: E/AndroidRuntime(8997): at android.view.HardwareRenderer$GlRenderer.draw(HardwareRenderer.java:1182)
04-25 21:05:50.387: E/AndroidRuntime(8997): at android.view.ViewRootImpl.draw(ViewRootImpl.java:2147)
04-25 21:05:50.387: E/AndroidRuntime(8997): at android.view.ViewRootImpl.performDraw(ViewRootImpl.java:2019)
04-25 21:05:50.387: E/AndroidRuntime(8997): at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:1830)
04-25 21:05:50.387: E/AndroidRuntime(8997): at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:998)
04-25 21:05:50.387: E/AndroidRuntime(8997): at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:4212)
04-25 21:05:50.387: E/AndroidRuntime(8997): at android.view.Choreographer$CallbackRecord.run(Choreographer.java:736)
04-25 21:05:50.387: E/AndroidRuntime(8997): at android.view.Choreographer.doCallbacks(Choreographer.java:566)
04-25 21:05:50.387: E/AndroidRuntime(8997): at android.view.Choreographer.doFrame(Choreographer.java:536)
04-25 21:05:50.387: E/AndroidRuntime(8997): at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:722)
04-25 21:05:50.387: E/AndroidRuntime(8997): at android.os.Handler.handleCallback(Handler.java:615)
04-25 21:05:50.387: E/AndroidRuntime(8997): at android.os.Handler.dispatchMessage(Handler.java:92)
04-25 21:05:50.387: E/AndroidRuntime(8997): at android.os.Looper.loop(Looper.java:137)
04-25 21:05:50.387: E/AndroidRuntime(8997): at android.app.ActivityThread.main(ActivityThread.java:4745)
04-25 21:05:50.387: E/AndroidRuntime(8997): at java.lang.reflect.Method.invokeNative(Native Method)
04-25 21:05:50.387: E/AndroidRuntime(8997): at java.lang.reflect.Method.invoke(Method.java:511)
04-25 21:05:50.387: E/AndroidRuntime(8997): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:786)
04-25 21:05:50.387: E/AndroidRuntime(8997): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
04-25 21:05:50.387: E/AndroidRuntime(8997): at dalvik.system.NativeStart.main(Native Method)
UPD:动画在 aos 4.0.3 中有效,但在 4.1.1 中崩溃