I\'m new here in Android. I\'d like to make a Battery Charging Animation in the phone, for example, in the top-right of the screen, the small icon that is moving up
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.