I have made this splash screen for my app but im not sure whether is the best option. As it is sleeping the thread when the app is launching. Here is the code, I use navigation components so the weren´t tutorials available. SplashFragment.kt
class SplashFragment : Fragment() { private lateinit var rootview:View override fun onCreateView( inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle? ): View { // Inflate the layout for this fragment splash() rootview = inflater.inflate(R.layout.fragment_splash, container, false) return rootview } fun splash(){ Thread(Runnable { Thread.sleep(500) findNavController().navigate(R.id.action_splahFragment_to_loginFragment) }).start() } }
https://stackoverflow.com/questions/66057439/is-it-safe-to-make-a-splash-screen-this-way February 05, 2021 at 12:06PM
没有评论:
发表评论