You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The main activity theme of my application is not set properly on Capacitor 3 by BridgeActivity and the background of the main activity is the splash screen.
I found this issue after upgrading to Capacitor 3 and you can reproduce it by opening the application keyboard. While the keyboard is being opened, pay attention to the gap that appears between the keyboard and your application content during 1s approx. because if your splash screen is pink, this gap will look pink. On Capacitor 2 this gap was black and that is the expected behavior. Please, have a look at the video:
After a deep investigation on the bridge activity tasks, I think that the activity theme is set up too late to '@style/AppTheme.NoActionBar', whose background is set up to black by default, what makes the activity still use the theme that says AndroidManifest which is '@style/AppTheme.NoActionBarLaunch', whose background is set up with the splash screen.
If you have a look at the implementation, you can realize that the theme is set up during the 'onStart' life cycle because it is there where the bridge and its plugins are initialized automatically.
Before Capacitor 3, this doesn't happen because it was necessary to invoke 'init' (BridgeActivity method) from 'onCreate' of the application main activity to initialize all Capacitor plugins. Apart from configuring the plugins, this 'init' method also sets up the activity theme, etc. And it seems correct the place and moment where/when the theme should be set up.
To sum up, the difference between Capacitor 2 and Capacitor 3 is that the Capacitor 2 sets up the theme during 'onCreate' method and Capacitor 3 during 'onStart'. In fact, if I force to set the activity theme into the 'onCreate' method of my main activity works:
And calling the 'init' method into the 'onCreate' of the main activity also works properly, although it is highly discouraged by Capacitor because the plugins are not registered automatically by doing this. (NOT TO DO THIS)
From my point of view, Capacitor 2 behavior is right and the main activity background should be dark or the value configured in the '@style/AppTheme.NoActionBar' theme.
Code Reproduction
Not provided.
Other Technical Details
npm --version output:
6.14.8
node --version output:
v14.15.0
pod --version output (iOS issues only):
1.10.1
Additional Context
While the issue is being investigated I suggest to set the activity theme into the 'onCreate' method of your main activity.
Thanks for the issue! This issue is being locked to prevent comments that are not relevant to the original issue. If this is still an issue with the latest version of Capacitor, please create a new issue and ensure the template is fully filled out.
Bug Report
Capacitor Version
Platform(s)
Current Behavior
The main activity theme of my application is not set properly on Capacitor 3 by BridgeActivity and the background of the main activity is the splash screen.
I found this issue after upgrading to Capacitor 3 and you can reproduce it by opening the application keyboard. While the keyboard is being opened, pay attention to the gap that appears between the keyboard and your application content during 1s approx. because if your splash screen is pink, this gap will look pink. On Capacitor 2 this gap was black and that is the expected behavior. Please, have a look at the video:
Grabacion.de.pantalla.2021-07-02.a.las.10.34.15.mov
After a deep investigation on the bridge activity tasks, I think that the activity theme is set up too late to '@style/AppTheme.NoActionBar', whose background is set up to black by default, what makes the activity still use the theme that says AndroidManifest which is '@style/AppTheme.NoActionBarLaunch', whose background is set up with the splash screen.
https://github.com/ionic-team/capacitor/blob/3.0.2/android/capacitor/src/main/java/com/getcapacitor/BridgeActivity.java#L65
If you have a look at the implementation, you can realize that the theme is set up during the 'onStart' life cycle because it is there where the bridge and its plugins are initialized automatically.
https://github.com/ionic-team/capacitor/blob/3.0.2/android/capacitor/src/main/java/com/getcapacitor/BridgeActivity.java#L111
https://github.com/ionic-team/capacitor/blob/3.0.2/android/capacitor/src/main/java/com/getcapacitor/BridgeActivity.java#L65
Before Capacitor 3, this doesn't happen because it was necessary to invoke 'init' (BridgeActivity method) from 'onCreate' of the application main activity to initialize all Capacitor plugins. Apart from configuring the plugins, this 'init' method also sets up the activity theme, etc. And it seems correct the place and moment where/when the theme should be set up.
To sum up, the difference between Capacitor 2 and Capacitor 3 is that the Capacitor 2 sets up the theme during 'onCreate' method and Capacitor 3 during 'onStart'. In fact, if I force to set the activity theme into the 'onCreate' method of my main activity works:
And calling the 'init' method into the 'onCreate' of the main activity also works properly, although it is highly discouraged by Capacitor because the plugins are not registered automatically by doing this. (NOT TO DO THIS)
Expected Behavior
From my point of view, Capacitor 2 behavior is right and the main activity background should be dark or the value configured in the '@style/AppTheme.NoActionBar' theme.
Code Reproduction
Not provided.
Other Technical Details
npm --version
output:6.14.8
node --version
output:v14.15.0
pod --version
output (iOS issues only):1.10.1
Additional Context
While the issue is being investigated I suggest to set the activity theme into the 'onCreate' method of your main activity.
The text was updated successfully, but these errors were encountered: