When I move from one Activity to another Activity, a white screen is displayed for 2 seconds. I am using this code:
Intent intent = new Intent(this, SecondActivity.class); startActivity(intent);
How can I resolve this issue?
Amsheer : No server calls. FirstActivity has MoodStock Scanner Camera. Second Activity contains just one Text "hello world".
Commented Oct 16, 2015 at 10:23Create a Theme like this:
Apply this theme to your second activity
answered Jun 14, 2017 at 19:29 Ziwei Zeng Ziwei Zeng 701 5 5 silver badges 21 21 bronze badges Worked for me too. Thank you. Commented Jul 30, 2017 at 8:08 what this actually do? Commented Feb 26, 2018 at 11:42 Its delaying activity loading time. Commented Mar 6, 2018 at 13:14by adding that line its not taking one click to open the app . It's taking two clicks and after the second click it holds for 2 sec and launches the app
Commented Apr 27, 2018 at 9:03What if I don't have an activity to implement the style? for example, when i just want to open a new browser from my app. When I back to my app i see the blank white screen. Intent intent = new Intent(Intent.ActionView); intent.AddFlags(ActivityFlags.ClearTop); intent.SetData(Android.Net.Uri.Parse(url)); context.StartActivity(intent); Can you please help?
Commented Sep 15, 2020 at 4:27If your activity contains more complex layouts, do not use finish() after setting flag. Use FLAG_ACTIVITY_CLEAR_TOP and _TASK instead and it will solve your problem.This worked for me perfectly
Intent intent = new Intent(this, SecondActivity.class); intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK|Intent.l̥FLAG_ACTIVITY_CLEAR_TOP ); startActivity(intent);
or use simply like below
Intent intent = new Intent(this, SecondActivity.class); startActivity(intent);
answered Dec 16, 2016 at 6:50 5,511 4 4 gold badges 39 39 silver badges 51 51 bronze badges Unfortunately it doesn't finish your current activity. Commented Jan 4, 2018 at 7:07While switching from ActivityOne to ActivityTwo, till ActivityTwo onCreate method gets executed default background is shown which is the white/black screen. Good practise is don't do heavy operation in onCreate. To fix the issue set transparent background to ActivityTwo as shown below.
In Manifest set above theme
answered Feb 6, 2018 at 11:06 547 4 4 silver badges 5 5 bronze badgesTry adding intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); before calling startActivity(intent);
Intent intent = new Intent(this, SecondActivity.class); intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); startActivity(intent);