Getting black screen on activity change

I am facing black screen issue when changing activity from one to another. I found an answer as to why this is happening but cannot find a solution for it. When I go from my playActivity to GameCompleteActivity, from where I can go to the next level, going to the next level, I end up with a playActivity instance and naming a new Intent for the same PlayActivity, because my different level is running in PlayActivity, due to my requirement I must finish the last playActivity in order to start a new playActivity for the next Level. This is where I get a lag or black screen going to the next level i.e. after finishing and starting the game again. It takes time.

I tried Transculent.Theme but it didn't work. AsyncTask also didn't give me the desired result

Now it felt like I was showing some kind of activity fade animation or something that might hide my black screen behavior?

need help solving? .... thanks

+3


source to share


5 answers


This usually means that a new activity is loading data onto the UI thread, so the screen stays black until everything is loaded.



Consider moving the code that loads all of the Activity data (it's a game, so I think level and graphics) in a separate thread, and then lets PlayActivity know when the data is ready to use.

+5


source


Whenever things like this happen, remember to debug when calling a new activity.



When creating any game, try making sections of different modules. So it's easy to track your problem.

0


source


If you have some heavy UI related code in your onCreate just try to do outside of onCreate by creating some IntializeUI () function and maybe try to split it into modular or use the Transculent theme for your activity ...

0


source


This is a very simple mistake: just put your activity: android: theme = "@android: style / ... in your manifest file, and make it transparent.

0


source


While it is possible that too much activity on the main thread will do this, in my experience the most common / notable reason is to call finish () immediately after startActivity () on transition. Not to say that this is wrong, but if you want to get rid of the black screen, you may need to try a different approach, such as using noHistory .

0


source







All Articles