Each version update of Android has many new features that are expected, along with the addition of new classes or enhancement of some class functions in the API.
However, compatibility issues will be added. For example, after Android, you can directly call
Overridependingtransition (INT, INT) to implement the activity jump animation. But there is no such method in the API before 2.0.
Therefore, your program cannot run in versions earlier than Android. Considering compatibility issues, you may choose not to use the new method.
Is there a simple and compatible method? The answer is yes. It can be called using reflection. The Code is as follows:
Try {
// For Android> 2.0
Method methid = activity. Class. getmethod ("overridependingtransition", integer. type, integer. type );
Method. invok (youractivity, R. anim. zoom_in, R. anim. zoom_out );
} Catch (nosuchmethodexception e ){
// For Android <2.0
// Complete by other ways.
// You code...
} Catch (otherexception ex ){
Throw (Ex );
}
For new classes, some processing can also be done through reflection. Here we will not list them one by one. Readers can think about it and get their own solutions.
I haven't updated my blog for a long time. I feel that this question can be explained in a few words, so I can write it down and hope it will be helpful to some friends.