How do I call an activity from my splash screen using threads. just guide me in java code i.e how do i create a thread and call my next activity.
Asked
Active
Viewed 511 times
-2
-
2Please change the title of your question to something more specific (less generic). – Emond Jan 16 '12 at 06:37
-
4do you have google? If yes then search it you will get as many answers you want for this. – Lalit Poptani Jan 16 '12 at 06:38
-
possible duplicate of [How do I make a splash screen in android](http://stackoverflow.com/questions/5486789/how-do-i-make-a-splash-screen-in-android) – Lalit Poptani Jan 16 '12 at 07:41
1 Answers
1
If you want to display the second activity from your SplashActivity : Note: SplashActivity will be the Startup Activity in manafist
<activity android:name=".SplashActivity"
android:label="@string/app_name">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
protected boolean _active = true;
protected int _splashTime = 5000;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.splash);
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();
startActivity(new Intent("com.package.AppName.SecondActivity"));
}
}
};
splashTread.start();
}
hope this will help you.

Basbous
- 3,927
- 4
- 34
- 62
-
Thankyou BasBous, I couldn't see my splash when i run my project, directly the SecondActivity is visible. How come? – shrikantbhr Jan 16 '12 at 07:03
-
you wanna show the spalsh screen after the spalsh is disappear you wanna start the second activity – Basbous Jan 16 '12 at 07:21
-
display the splash first and then connecting to it secondavtivity. – shrikantbhr Jan 16 '12 at 07:24
-
-
you can replace all line of code to this startActivity(new Intent(SplashActivity.this, SecondActivity.class)); – Basbous Jan 16 '12 at 09:42
-
01-16 15:28:26.025: ERROR/AndroidRuntime(1079): android.content.ActivityNotFoundException: No Activity found to handle Intent { act=PhoneDirectory.this, Login.class } – shrikantbhr Jan 16 '12 at 10:02
-
-
-
-
-