Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trial
Matheus G Oliveira
9,682 PointsScreen before the app starts
Hello,
There is any way to get a screen before the app starts (MainActivity is called) ?
Like, a screen that appear when i press the app icon, it stays there for 2 seconds and automatically go to MainActivity.
Cheers
1 Answer
ryanloerzel
12,671 PointsIn the onCreate method you could start a new intent to take you to your splash screen:
Intent intent = new Intent (MainActivity.this,MySplashScreenActivity.class);
startActivity(intent);
Then you could set a timer in the onCreate method of your MySplashScreenActivity.class to bring you back to the MainActivity:
Timer timer = new Timer();
timer.schedule(new TimerTask() {
@Override
public void run() {
finish(); //finish this activity and return to the calling activity (MainActivity)
}
},5*1000); // wait 5 sec
There is probably a more eloquent solution, and I would also be interested to see how others accomplish this.
Matheus G Oliveira
9,682 PointsMatheus G Oliveira
9,682 PointsThank you man!!! Helped a lot.
The code below was useful for me to complete what you helped me to.
I hope it helps you too.
It is to make a fullscreen on the activity you want: (in my case, the startscreen should appear on fullscreen)
on the OnCreate method:
Cheers!