简体   繁体   English

如何使用 android:windowBackground 方法实现 Application.ActivityLifecycleCallbacks 以为 Android 应用程序制作启动画面

[英]How to implement Application.ActivityLifecycleCallbacks to make a splash screen for an Android app using the android:windowBackground method

Android Studio Intermediate here with what I hope is not a redundant question: Android Studio Intermediate 这里我希望这不是一个多余的问题:

I encountered an issue while building a splash screen for the very first time.我在第一次构建启动画面时遇到了一个问题。 I'm following the process posted here by David Medenjak, which encourages to use a theme in order to have it be displayed while the app is in the process of booting up:我正在关注 David Medenjak 在此处发布的流程,该流程鼓励使用主题以便在应用程序启动过程中显示它:

https://blog.davidmedenjak.com/android/2017/09/02/splash-screens.html https://blog.davidmedenjak.com/android/2017/09/02/splash-screens.html

I followed this very closely and am certain everything should be in order.我非常密切地关注这一点,并且确信一切都应该井井有条。

The very last step for basic functionality, titled "Registering the Splash Screen", suggests building a java file to handle switching to your application once it finishes loading.基本功能的最后一步,标题为“注册启动画面”,建议构建一个 java 文件,以便在完成加载后处理切换到应用程序。 The java code provided on the blog implements an abstract class called Application.ActivityLifecycleCallbacks, yet the code provided does not implement the obstract methods of this superclass.博客上提供的 java 代码实现了一个名为 Application.ActivityLifecycleCallbacks 的抽象 class,但提供的代码没有实现这个超类的抽象方法。

I did some research on how to implement this superclass but I'm not familiar with it enough to know how to do so and retain the functionality I need.我对如何实现这个超类进行了一些研究,但我对它不够熟悉,无法知道如何做到这一点并保留我需要的功能。 My java class looks just like the one described in the blog.我的 java class 看起来就像博客中描述的一样。

Here is another guide on this superclass I found to help with implementing, which implements very few methods:这是我发现有助于实现的这个超类的另一个指南,它实现了很少的方法:

https://medium.com/@mobile_develop/android-application-development-detecting-when-your-app-enters-the-background-or-foreground-bbced47ad8a5 https://medium.com/@mobile_develop/android-application-development-detecting-when-your-app-enters-the-background-or-foreground-bbced47ad8a5

I apologize if the answer is obvious.如果答案很明显,我很抱歉。 My hope is to communicate with David, since he's active on StackOverflow.我希望与 David 交流,因为他在 StackOverflow 上很活跃。 Maybe @'ing him to this thread would work.也许@'ing他到这个线程会起作用。 Any tips on how to implement the class (if necessary) would be greatly appreciated.任何有关如何实现 class(如有必要)的提示将不胜感激。

For the abstract methods that are not implemented in the super class, simply implement them as empty method definitions.对于超class中没有实现的抽象方法,只需将它们实现为空方法定义即可。 The Example you can refer to is the following from the blog author's included source .您可以参考的示例是博客作者包含的源代码中的以下内容。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM