Animation in status bar in Android

穿精又带淫゛_ 提交于 2019-12-01 13:30:40

Starter class should implement also stop logic. Something like:

class Starter implements Runnable {
    boolean stopConditionMet = false;
    public void run() {
        BatteryAnimation.start();
        try {
         while (!stopConditionMet) { Thread.sleep(500); } 
        } catch (InterruptedException e) {}
         BatteryAnimation.stop();

    }
    public void stop() { stopConditionMet=true; }

}

(instead of busy wait you can do this with wait()-notifyAll() scheme. The above example if for simplicity).

.. and you'll need to keep the instance of the Starter class inside your Activity. Declaring it anonymously won't allow you to change its value when you need.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!