I am using the following splash screen code with an onTouchEvent method. I am getting ANR's and do not know what to do. The app works perfectly, except occasionally it locks up with a Sorry, Activity xxx is not responding. Any ideas?
_splashTime = 5000 ; // approx 5 seconds
public boolean onTouchEvent(MotionEvent event) {
if (event.getAction() == MotionEvent.ACTION_DOWN) {
_active = false;
}
return true;
}
Thread splashTread = new Thread() {
@Override
public void run() {
try {
int waited = 0;
while(_active && (waited < _splashTime ))
{
sleep( _waitsecs );
if ( _active ) {
waited += _waitsecs ;
}
}
}
catch(InterruptedException e) {
// do nothing with catch
}
finally {
start_program();
finish();
}
}
};
splashTread.start();