dimanche 3 juillet 2016

I have NullPointerException error only in real devices [on hold]

I got a strange (for me) NullPointerException error with my code, it's happends only in real devices, but on emulators, it's works just fine!!

here's the code:

@Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);

        logo = (ImageView) findViewById(R.id.logo);

}
    private void flyIn() {
        animation = AnimationUtils.loadAnimation(this, R.anim.logo_animation);     //<-- this line here 
        logo.startAnimation(animation);

    }

logo_animation looks like :

<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android"
    android:fillAfter="true"
    android:fillEnabled="true" >

    <scale
        android:duration="1500"
        android:fromXScale="0.1"
        android:fromYScale="0.1"
        android:interpolator="@android:anim/accelerate_interpolator"
        android:pivotX="50%"
        android:pivotY="50%"
        android:toXScale="1"
        android:toYScale="1" />

    <rotate
        android:duration="1500"
        android:fromDegrees="-270"
        android:interpolator="@android:anim/accelerate_interpolator"
        android:pivotX="50%"
        android:pivotY="50%"
        android:toDegrees="0" />

    <alpha
        android:duration="1500"
        android:fromAlpha="0"
        android:toAlpha="1" />

</set>

at this line, the NPE problem appears. animation = AnimationUtils.loadAnimation(this, R.anim.logo_animation);

Can someone explains me what's going on?? Thank you very much!! and sorry for my english :)

Aucun commentaire:

Enregistrer un commentaire