Android Question activity is black at the very start

peacemaker

Expert
Licensed User
Longtime User
For part os second of the very first start.
Why ? How to change ? Color of the main activity does not help.
Other apps has white initial screen, or not mono-color (or it's maybe very fast start).
 

DonManfred

Expert
Licensed User
Longtime User
depends on what you are doing in Activity_create. Usually it should be happen for SECONDS...

Did you forgot to load a layout?

Create a small project which shoes the problem.
 
Last edited:
Upvote 0

peacemaker

Expert
Licensed User
Longtime User
Yes, _Create is rether long, including loading a layout...
Blank sample project has the black initial screen also, but for very short time.

I'm using a splash screen lib, but it does not help...
So - _Create must be very fast to minimize this black screen...

But is it possible to preset the color of this .... black one ?
 
Upvote 0

sorex

Expert
Licensed User
Longtime User
maybe this helps

change activity color in code
init a timer of 5ms
in timer_tick disable timer and do the loadlayout there

the color might change immediatly without waiting for the refresh of the long loading loadlayout
 
Upvote 0

peacemaker

Expert
Licensed User
Longtime User
SetApplicationAttribute(android:theme, @android:style/Theme.Translucent)
it helps to avoid the issue completely... but has some other visual "defects" :( (EditTexts lost the borders...)
 
Upvote 0

peacemaker

Expert
Licensed User
Longtime User
maybe this helps

change activity color in code
init a timer of 5ms
in timer_tick disable timer and do the loadlayout there

the color might change immediatly without waiting for the refresh of the long loading loadlayout

It's wrong way: Activity_Resume goes just after Activity_Create and app force closed, as not all inited before it starts.
 
Upvote 0

peacemaker

Expert
Licensed User
Longtime User
NOT SOLVED, see below:

B4X:
In Manifest:

SetActivityAttribute(Main, android:theme, @style/CustomActTheme)
CreateResource(values, theme.xml,
<resources>
  <style name="CustomActTheme" parent="@android:style/Theme.Holo">
  <item name="android:windowIsTranslucent">true</item>
  <item name="android:windowBackground">@android:color/transparent</item>
  <item name="android:windowContentOverlay">@null</item>
  <item name="android:windowNoTitle">false</item>
  <item name="android:backgroundDimEnabled">true</item>
  <item name="android:windowFullscreen">false</item>
</style>
</resources>
)
 
Last edited:
Upvote 0

Erel

B4X founder
Staff member
Licensed User
Longtime User
You are forcing your app to use the old holo theme. It will look bad on new devices.

It is better to set the theme based on the device version.

Example:
B4X:
SetApplicationAttribute(android:theme, "@style/LightTheme")
CreateResource(values-v20, theme.xml,
<resources>
  <style
  name="LightTheme" parent="@android:style/Theme.Material.Light">
  </style>
</resources>
)
CreateResource(values-v14, theme.xml,
<resources>
  <style
  name="LightTheme" parent="@android:style/Theme.Holo.Light">
  </style>
</resources>
)
 
Upvote 0

peacemaker

Expert
Licensed User
Longtime User
Thanks, Erel.

I made so:
B4X:
SetApplicationAttribute(android:theme, "@style/LightTheme")
CreateResource(values, theme.xml,
<resources>
  <style
  name="LightTheme">
  <item name="android:windowIsTranslucent">true</item>
  <item name="android:windowNoTitle">false</item>
  <item name="android:windowFullscreen">false</item>
  </style>
</resources>
)

Seems, OK. Or some hidden issues ?
 
Upvote 0

peacemaker

Expert
Licensed User
Longtime User
No, my latest variant gives strange trouble: after going between several activities - at the Main activity start - _Resume occures, but hungs and no activity interface update, and no ForceClose offer, previous activity is still visible.
If to remove this code from the manifest - no such trouble. Tested under Android 4.2 and 7.0.
 
Upvote 0

peacemaker

Expert
Licensed User
Longtime User
Thanks, but it does not help - early or sooner, if a theme is applied by manifest - some is stuck and latest opened activity does not respond to taps at all. Without it - no problem.
All these only for avoiding initial black starting activity...
At starting these settings are not applied yet:

B4X:
#Region  Activity Attributes
    #FullScreen: False
    #IncludeTitle: false
#End Region

Title is visible, activity is black, before loading a layout.
At least, it would be OK to change the color and hide the title during start...

No way to avoid it without any theme modifications ?
 
Upvote 0

peacemaker

Expert
Licensed User
Longtime User
SOLVED:
B4X:
SetActivityAttribute(Main, android:theme, @style/CustomActTheme)
CreateResource(values, theme.xml,
<resources>
  <style name="CustomActTheme">
  <item name="android:windowBackground">@android:color/transparent</item>
  <item name="android:windowNoTitle">true</item>
  <item name="android:windowFullscreen">false</item>
</style>
</resources>
)
 
Upvote 0

giggetto71

Active Member
Licensed User
Longtime User
hi @peacemaker, I have the same problem with the activity black and even after applying the mods in the manifest that solved the issue for you I still have the activity starting as black before loading the layout. any tips?
 
Upvote 0

peacemaker

Expert
Licensed User
Longtime User
No tips since 2017 :)
Investigate from the scratch
 
Upvote 0

peacemaker

Expert
Licensed User
Longtime User
I do not remember yesterday's breakfast, why to ask about 2017's things :)
 
Upvote 0
Top