Categoryreflection

Java Bomb

That’s just brilliant!

http://thedailywtf.com/Articles/Disgruntled-Bomb-Java-Edition.aspx

//DL

Disable animation between Activities in Android

Sometimes you may want to disable Activity start/end animation. Here’re some tricks how to do this.

  1. Use FLAG_ACTIVITY_NO_ANIMATION flag. If you compile your code for 1.5 – just use 65536
    Intent intent = new Intent(xxx);
    intent.addFlags(65536); // no animation (api 5)
    startActivity(intent);
    
  2. But you will still have animations after finish() events in your Activity. To remove this – call overridePendingTransition function (Activity class, api 5) with zero arguments right after finish().
    If you compile your code for 1.5… just use reflection! 🙂

    Class myTarget;
    Class[] paramTypes = {
           Integer.TYPE, Integer.TYPE
    };
    Method myMethod = null;
    ...
    try {
        myTarget = Class.forName("android.app.Activity");
        myMethod = myTarget.getDeclaredMethod("overridePendingTransition", paramTypes);
    } catch (Exception e) {
        e.printStackTrace();
    }
    ...
    finish();
    try {
        myMethod.invoke(this, 0, 0); // this - your Activity instance
    } catch (Exception e) {
        e.printStackTrace();
    }
    

//DL

© 2019 Android Tales

Theme by Anders NorenUp ↑