Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Main screen goes black if we switch between apps #12

Open
bajajsahil opened this issue Jan 30, 2021 · 5 comments
Open

Main screen goes black if we switch between apps #12

bajajsahil opened this issue Jan 30, 2021 · 5 comments

Comments

@bajajsahil
Copy link

If TrueCaller bottom sheet is opened and during that, if we switch between apps then the screen blacks out.

Flutter Doctor

[√] Flutter (Channel stable, 1.22.4, on Microsoft Windows [Version 10.0.17134.165], locale en-IN)
• Flutter version 1.22.4 at \fultter\flutter
• Framework revision 1aafb3a8b9 (3 months ago), 2020-11-13 09:59:28 -0800
• Engine revision 2c956a31c0
• Dart version 2.10.4

[√] Android toolchain - develop for Android devices (Android SDK version 29.0.2)
• Android SDK at \install\AndroidSDK
• Platform android-30, build-tools 29.0.2
• ANDROID_HOME = \install\AndroidSDK
• Java binary at: \install\Android Studio\jre\bin\java
• Java version OpenJDK Runtime Environment (build 1.8.0_242-release-1644-b01)
• All Android licenses accepted.

[√] Android Studio (version 4.0)
• Android Studio at \install\Android Studio
• Flutter plugin version 45.1.2
• Dart plugin version 193.7361
• Java version OpenJDK Runtime Environment (build 1.8.0_242-release-1644-b01)

[√] Connected device (1 available)
• SM G960F (mobile) • 231173e32f027ece • android-arm64 • Android 10 (API 29)

issue

@parth0907
Copy link

Hi Sahil,

Hope you are doing great!

PFB the resolution for the flutter issue shared earlier :

It appears that apparently when an app is resumed from the background, the Flutter engine isn't able to apply the default translucent layer for Popup and Bottomsheet and hence a black background appears (since that's the default theme). The fix is to simply manually apply this background to the activity. This can be done by overriding the getBackgroundMode() method in the launcher activity like this -

class MainActivity : FlutterFragmentActivity() {
override fun configureFlutterEngine(flutterEngine: FlutterEngine) {
GeneratedPluginRegistrant.registerWith(flutterEngine)
}
override fun getBackgroundMode(): FlutterActivityLaunchConfigs.BackgroundMode {
return FlutterActivityLaunchConfigs.BackgroundMode.transparent
}

Please feel free to reach us via our support channel https://developer.truecaller.com/support in case you have further issues for a faster and dedicated response.

Regards,
Parth

@bajajsahil
Copy link
Author

Thanks Parth. It worked.

@bajajsahil
Copy link
Author

Hi @parth0907, this solution is causing an issue with Flutter 2.5. I am seeing black screen on the launch of the app intermittently. It could be due to the change in splash screen in 2.5 - https://flutter.dev/docs/development/ui/advanced/splash-screen

If I remove the code provided by you then I don't see this launch black screen issue but our original issue starts coming again.

Can you look? Thanks.

@bajajsahil bajajsahil reopened this Sep 22, 2021
@parth0907
Copy link

Hi @bajajsahil

Hope you are doing great!

Since we already have an example project in our Flutter repo, I would request you to provide the steps specific to this example project as to what changes need to be made to which file of this project for us to reproduce this.

Once you share the steps, we shall investigate this at our end.

Regards,
Parth

@bajajsahil
Copy link
Author

Hi @parth0907

I am able to reproduce with example project as well.

As per Flutter 2.5, we need to remove below code from android\app\src\main\AndroidManifest.xml

<meta-data
                android:name="io.flutter.embedding.android.SplashScreenDrawable"
                android:resource="@drawable/launch_background" />

Now you have provided the below fix in MainActivity for the original problem.

override fun getBackgroundMode(): FlutterActivityLaunchConfigs.BackgroundMode {
	return FlutterActivityLaunchConfigs.BackgroundMode.transparent
}

Behavior with your fix(Intermediate black screen is coming)

With_Your_FIx.mp4

Behavior without you fix(no black screen is coming after launch screen)

Without_Your_Fix.mp4

Let me know if any more info is needed.

Thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants