Android : White screen when relaunch app - android

I have a problem of white screen when I relaunch background app.
I click home button and then I click on app logo, my application resume and sometimes I have a white screen.
Do you know what's happening please?

This is the time that your application takes starting, before first activity is displayed.
If you extended the application class, you can look at the onCreate method, if there is much code here.
You can minimize the effects, setting the default window background to a color or drawable in a theme:
<item name="android:windowBackground">#color/mycolor</item>

Related

How get rig of the starting non-seen activity?

I have an app where I used the dark theme. I have also added a splash screen where I have added an animation. The background of the SplashActivity is white. When I first start the app, I get a dark screen and then the splash screen is displayed. How to get rid of that dark screen and see directly the splash screen? Thanks
Its related to Cold Start. It happens when your app starts for the first time as explained in the android documentation. However to deal with it I prefer the solution of having background drawable and set it to app theme if your Splash screen is static but in your case as you are using animations you need to use mixture of both techniques i.e. setting the splash screen theme as drawable which is loaded during cold start and later on when it finishes you render your animated stuff.

Android : White screen on app reload. How to avoid?

I've read every questions on this site about how to put a splash screen on app start-up to avoid the white screen problem. However the white screen still pops-up when the app has been in the background for a while. Is there anyway to either make it transparent or redirect the app to the splash screen if the app has been in the background for a while?
To get rid of the white screen which is because of android's cold start, and appears when the app loads to memory, you can add the following style item to your AppTheme.
<item name="android:windowDisablePreview">true</item>

Is making Activity theme translucent correct to avoid white Screen?

After a long time search in Google, I found many users saying to make the main Activity as translucent to avoid the white screen while opening the application.
Also, I observed that clicking on the app icon in then menu takes time to open the app when translucent is used.
Is this the correct way to avoid the white screen?

setTheme works but only after loading theme from manifest

I'm trying to set the theme of my Activity during runtime, choosing one of a number of themes. I want the chosen theme to display immediately on startup of the Activity.
In the <application> part of my manifest I have set a default theme with android:theme="#style/AppTheme". And then in my onCreate() I use setTheme(R.style.DarkAppTheme) to set the theme to a user-selected theme (replacing DarkAppTheme with the selected theme).
And based on research it seems that setTheme() should go before onCreate() and before setContentView(), which I do.
BUT although this works to display the Activity in the user selected theme, the Activity first loads with what looks like the default theme, and then after a short delay the correct theme loads.
If I set the user selected theme directly in the manifest, that loads immediately as I want, but of course that is hardcoded and I want to change this dynamically based on a shared preference.
How do I avoid the visible changeover? I want the user selected theme to be displayed right from the start.
Thanks.
The Activity first loads with what looks like the default theme, and then after a short delay the correct theme loads... How do I avoid the visible changeover?
There are 2 parts to an Activity 'Enter/Opening' window animation, when your app is first launched from the icon on the Home Screen:
The 'dark gray rectangle appear' animation. This is the initial blank screen that the system process draws when launching the app (source). It's also known as the "theme preview" screen or "splash screen". It can be white if your app uses a Light theme.
The 'fade in (or circular reveal) of the view layout'. This is the animation of your view layout appearing on top of the dark gray rectangle. It happens after part 1.
Part 1 is what you identified as "what looks like the default theme". You can disable this first part with the following item in your Activity/App style:
<item name="android:windowDisablePreview">true</item>
This will prevent the 'dark gray rectangle appear' animation, and only allow the 'reveal of the view layout', to therefore avoid the visible changeover or flicker. But there are caveats:
You have to ensure that your Activity launches quickly, because there will be no visual animation feedback for the user until your layout is fully loaded. That's why the theme preview is normally on by default.
It causes strange bugs on context menus: For any PopupWindow, the 'Enter' animation will no longer happen, and it will just display instantly ('Exit' animations are not affected). This also applies to system PopupWindows like the overflow menu list, and the drop-down list of an AutoCompleteTextView. This bug happens on Android 4/5/6, but not on Android 7/8. More info here.
Documentation of windowDisablePreview:
Flag allowing you to disable the splash screen for a window. The default value is false; if set to true, the system can never use the window's theme to show a splash screen preview before your actual instance is shown to the user.
Further info:
How to set a theme to whole application in code, but not in the Manifest?
Android - Disable dummy starting window of application
The theme on AndroidManifest just appears if your Activity take too long to load. You can try to tunning up Activity load and remove android:theme="#style/AppTheme" from AndroidManifest or even set a compromise between these two use.
I hope it helps you \o/

Flash of activity with dark background while created

I have an activity with bark background launched as singleInstanse, and when it's starts the first time it has a shot white flash (white background shown) before showing its content. How can I prevent that? Or may be it is possible set up activity's default background color at start? Thanks.
This is due to what is called the preview window during app launching.
A very clear explanation of the issue and how to get around it is given by Cyril Mottier in android-app-launching-made-gorgeous
your app theme should have background color... thid color will replace the dark screen.

Categories

Resources