How to avoid black screen while invoking another activity in android?

Deadly 提交于 2019-12-18 05:11:11

问题


i am invoking an activity using intent from main activity. But during the invocation few system dialog boxes are displayed because of which a black screen is displayed. How can i avoid such black screen.


回答1:


Please check the flags you are setting in your intent.

If you have a finish(); or FLAG_ACTIVITY_CLEAR_TASK - a blank screen may show up on pre ICS devices as the current activity has been cleared before another activity is started.

Intent intent = new Intent(getApplicationContext(), Activity.class);
intent.setFlags(Intent.FLAG_ACTIVITY_NO_ANIMATION);
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
startActivity(intent);
overridePendingTransition (0, 0);



回答2:


If you want to finish the current activity during switching to other, call finish() after startActivity() method.

Checkout any long running or heavy tasks under the onCreate() method of new activity, it will block the activity onload untill the tasks has been finish.

Also check some transition properties ot other window flags these may also be the reasons in some cases.



来源:https://stackoverflow.com/questions/14501213/how-to-avoid-black-screen-while-invoking-another-activity-in-android

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!