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
Farouk Charkas
1,957 PointsWhat in the Android Feedback does this mean?
I have created a splash screen for my application and I have timed it for 5 seconds, I run the app, Splash Screen, CHECK. 5 seconds, CHECK. But it crashes afterwards. How do I fix this. This is what I get Skipped 213 frames! The application may be doing too much work on its main thread. What does "Skipped 213 frames" mean?
Farouk Charkas
1,957 PointsThank you for taking notice karis hutcheson,
This is my code: package everingapplications.fishinglife;
//Importing the stuff needed for making MainActivity.java work import android.support.v7.app.AppCompatActivity; import android.os.Bundle; import android.view.Menu; import android.view.MenuItem;
import java.util.Timer; import java.util.TimerTask; //Declaring the class MainActivity public class MainActivity extends AppCompatActivity {
@Override
//When MainActivity.java is being created/ran
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
//Set screen to R(File).layout(Second File).splashscreen(The Actual Display)
setContentView(R.layout.splashscreen);
//Creating the timer
Timer timer = new Timer();
//Telling the timer what to do
timer.schedule(new TimerTask() {
@Override
public void run() {
//Set screen to R(File).layout(Second File).homepage(The Actual Display)
setContentView(R.layout.homepage);
}
//This, divided by 1000 is how may seconds the timer will last
}, 3000
);
}
The code is supposed to display the homepage after 3 seconds.
Farouk Charkas
1,957 PointsThank you for taking notice karis hutcheson,
This is my code: package everingapplications.fishinglife;
//Importing the stuff needed for making MainActivity.java work import android.support.v7.app.AppCompatActivity; import android.os.Bundle; import android.view.Menu; import android.view.MenuItem;
import java.util.Timer; import java.util.TimerTask; //Declaring the class MainActivity public class MainActivity extends AppCompatActivity {
@Override
//When MainActivity.java is being created/ran
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
//Set screen to R(File).layout(Second File).splashscreen(The Actual Display)
setContentView(R.layout.splashscreen);
//Creating the timer
Timer timer = new Timer();
//Telling the timer what to do
timer.schedule(new TimerTask() {
@Override
public void run() {
//Set screen to R(File).layout(Second File).homepage(The Actual Display)
setContentView(R.layout.homepage);
}
//This, divided by 1000 is how may seconds the timer will last
}, 3000
);
}
The code is supposed to display the homepage after 3 seconds.
Farouk Charkas
1,957 PointsThank you for taking notice karis hutcheson,
This is my code: package everingapplications.fishinglife;
//Importing the stuff needed for making MainActivity.java work import android.support.v7.app.AppCompatActivity; import android.os.Bundle; import android.view.Menu; import android.view.MenuItem;
import java.util.Timer; import java.util.TimerTask; //Declaring the class MainActivity public class MainActivity extends AppCompatActivity {
@Override
//When MainActivity.java is being created/ran
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
//Set screen to R(File).layout(Second File).splashscreen(The Actual Display)
setContentView(R.layout.splashscreen);
//Creating the timer
Timer timer = new Timer();
//Telling the timer what to do
timer.schedule(new TimerTask() {
@Override
public void run() {
//Set screen to R(File).layout(Second File).homepage(The Actual Display)
setContentView(R.layout.homepage);
}
//This, divided by 1000 is how may seconds the timer will last
}, 3000
);
}
The code is supposed to display the homepage after 3 seconds.
1 Answer
karis hutcheson
7,036 PointsOkay, since I'm not in that lesson yet, I'm just going to venture a guess at fixing your problem. I've never seen a new task defined like you've done above with TimerTask. Not that I'm super experienced but I think that might be where the error is coming from where Android is having a hard time parsing out which run() method you're trying to @Override. You might try nesting a class declaration inside your onCreate() method and using that to extend and, then, overwrite the TimerTask run() method.
timer.schedule(new ChangeTask(), 3000);
class ChangeTask extends TimerTask {
@Override
public void run() {
setContentView(R.layout.homepage);
}
}
karis hutcheson
7,036 Pointskaris hutcheson
7,036 PointsCan we get some samples of the splash screen code? Also, what is the app doing directly after the splash screen? You might want to run through your code after the splash line-by-line in debug mode. I'm guessing that a variable is becoming overloaded or maybe you're using an infinitely recursive function for the splash?