Reputation: 8884
I want to wait for splash screen to finish his task and then to continue doing the activity. I think that my error is because too many time to wait for splash screen, my splash screen is for getting some string from server and its has all that need. the first class that creating and need to wait for splash screen finished is: Update:
Thread splashTread = new Thread() {
@Override
public void run() {
try {
splash splash=(tools.splash) new splash(first.this).execute();
int waited = 0;
while(splash.running && (waited< getResources().getInteger(R.integer.splashTimeOut)))
{
sleep(100);
if(splash.running) {
waited += 100;
}
// nextActivity=splash.newActivity;
}
} catch(InterruptedException e) {
// do nothing
} finally {
finish();
}
}
};
splashTread.start();
while the splash screen is ok its
public class splash extends AsyncTask<String, Void, String>
its wrong because its create a new activity and then do the thread....
Upvotes: 0
Views: 1820
Reputation: 119
public void onCreate(Bundle savedInstanceState) {
protected boolean _active = true;
protected int _splashTime = 1000;
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
Thread splashTread = new Thread() {
@Override
public void run() {
try {
int waited = 0;
while(_active && (waited < _splashTime)) {
sleep(100);
if(_active) {
waited += 100;
}
}
} catch(InterruptedException e) {
// do nothing
} finally {
finish();
}
}
};
splashTread.start();
Upvotes: 2
Reputation: 2927
I Hope My Code will be helpful to you
public void onStart()
{
super.onStart();
Thread background = new Thread(new Runnable()
{
public void run()
{
try
{
Thread.sleep(3000);
Intent langSelect = new Intent(EduApp.this, LanguageActivity.class);
startActivity(langSelect);
genHelper.goForwardScreen();
}
catch (Throwable t)
{
System.err.println("Thread Exception IN Splash Screen->" + t.toString());
}
}
});
background.start();
}
Start Next Activity Here..
Upvotes: 0