1

I need to implements animations in my android application.But All version of android os does not support that animation . Now I want to make that if target device’s os support animation then some animation’s code should be executed other wise not ..

For this, I have coded as follow ,

if(Build.VERSION.SDK_INT >= 7){overridePendingTransition(R.anim.slide_left_in,R.anim.slide_left_out);}

But it will crach when activity start as it raise error while build time.

Plz give me solution if possible

Thanks in advance.

nirav
  • 411
  • 2
  • 8
  • 18

3 Answers3

1

This has been addressed here on Android developer website. And take a look at Google I/O 2011, it has a good session on this, look at 6 minute mark of Android Protips: Advanced Topics for Expert Android App Developers session.

omermuhammed
  • 7,365
  • 4
  • 27
  • 40
0

Check this snippet:

int currentapiVersion = android.os.Build.VERSION.SDK_INT;
if (currentapiVersion >= android.os.Build.VERSION_CODES.FROYO){
    // Do something for froyo and above versions
} else{
    // do something for phones running an SDK before froyo
}
Mark Mooibroek
  • 7,636
  • 3
  • 32
  • 53
  • This won't work, since the bit of code for Froyo won't work on pre-Froyo devices. In particular, if it references Froyo-only classes, you'll raise a ClassNotFoundException as soon as this class is loaded. – Sean Owen May 18 '11 at 07:15
0

I think you can find an answer in this previous post.

Community
  • 1
  • 1
ol_v_er
  • 27,094
  • 6
  • 48
  • 61