Activityのジャンプアニメーションについて


詳細
1.6以降、すなわちAPI 5から、Activityジャンプ時のアニメーション効果を処理するためのoverridePendingTransition関数が追加される.ネット上では、多くの人が投稿したり転送したりしていますが、簡単な書き方を提供しています.
   
if (android.os.Build.VERSION.SDK_INT > android.os.Build.VERSION_CODES.DONUT) {

  overridePendingTransition(R.anim.push_up_in,R.anim.push_up_out);

}

しかし、この書き方はプロジェクトで使用すると問題が発生し、1.6のテストマシンでVerifyErrorのエラーが発生します.overridePendingTransitionはクラスロード時に呼び出され、1.6のマシンでプリコンパイルが行われるので、そのまま書くとエラーが発生します.
海外の某掲示板で検索してみると、
    The VM will attempt to find overridePendingTransition() when the class is loaded, not when that if() statement is executed.
    Instead, you should be able to do this:
    if (android.os.Build.VERSION.SDK_INT > android.os.Build.VERSION_CODES.DONUT) {
        SomeClassDedicatedToThisOperation.overridePendingTransition(this, ...);
    }
    where the implementation of overridePendingTransition() in SomeClassDedicatedToThisOperation just calls overridePendingTransition() on the supplied Activity.
    So long as SomeClassDedicatedToThisOperation is not used anywhere else, its class will not be loaded until you are inside your if() test, and you will not get the VerifyError.
ここでは解決策が明確に示されている.
処理方法:
   
public class AnimationModel {
    private Activity context;
    public AnimationModel(Activity context){
        this.context = context;
    }
    /**
     * call overridePendingTransition() on the supplied Activity.
     * @param a 
     * @param b
     */
    public void overridePendingTransition(int a, int b){
        context.overridePendingTransition(a, b);
    }

}

呼び出し方法:
   
if (android.os.Build.VERSION.SDK_INT > android.os.Build.VERSION_CODES.DONU) {
                    (new AnimationModel(Profile.this))
                            .overridePendingTransition(R.anim.push_up_in,
                                    R.anim.push_up_out);
                }

これにより、ジャンプアニメーション関数を参照するモデルクラスが生成されますが、中の関数は呼び出されません.これによりjvmにロードされません.問題も解決した.