I implemented some app, that waits about some time before action. User can go to preferences and define time to wait. My problem is now that if I press home button I can´t start any other app, because my app take all resources. I have an motorloa milestone and my code is (part of source code of waiting service) :
public void run() {
while(currentTime>waitingTime)
{ currentTime = System.currentTimeMillis();
Thread.sleep(1000);
}
//do Action
}
It is an simple thread, but it seems to be very ineffective. I would be very thanks-full for any help.
you can always use
Handlerto schedule aMessage. But your application needs to be in running state to get a call in Handler’s callback mathod(handleMessage(message)). Another option is to go forAlarmManger.