Skip to content

Snappy1

  • Home
  • Android
  • What
  • How
  • Is
  • Can
  • Does
  • Do
  • Why
  • Are
  • Who
  • Toggle search form

[FIXED] android – Redirecting to a different fragment once the timer is finished

Posted on November 11, 2022 By

Solution 1 :

I’m assuming you’re using androidx.navigation. If your aren’t, have a look at this: https://developer.android.com/guide/navigation/navigation-getting-started

override fun onViewCreated(view: View, savedInstanceState: Bundle?) {

    object : CountDownTimer(30000, 1000){
        override fun onFinish() {
            game_timer?.text = "Done"

            activity.findNavController( R.id.your_nav_host_in_your_activity).navigate(R.id.your_target_fragment )
        }

        override fun onTick(millisUntilFinished: Long) {
            game_timer?.text = "" + millisUntilFinished / 1000
        }

    }.start()

Problem :

I’m trying to make the fragment automatically redirect to another fragment once the timer has run out. How would I go about doing that? Thanks

override fun onViewCreated(view: View, savedInstanceState: Bundle?) {

    object : CountDownTimer(30000, 1000){
        override fun onFinish() {
            game_timer?.text = "Done"

        }

        override fun onTick(millisUntilFinished: Long) {
            game_timer?.text = "" + millisUntilFinished / 1000
        }

    }.start()

Comments

Comment posted by James Harden

Yes using navigation, But they all work through buttons, and I’m trying to get it to navigate without on click

Comment posted by Cory Roy

This should work, then if your time does. You’ll need to change the

Comment posted by James Harden

what would I have to put in the onFinish() to get it to redirecT? currently only have it to display done

Comment posted by Cory Roy

activity.findNavController( R.id.your_nav_host_in_your_activity).navigate(R.id.your_target_fragment )

READ  [FIXED] android - Flutter For Loop
Powered by Inline Related Posts
Android Tags:android, kotlin

Post navigation

Previous Post: [FIXED] Is it possible to switch from Start state to End state in android MotionLayout using Java/Kotlin?
Next Post: [FIXED] android – PHP / SQL: cannot save image at server but successful save image link at SQL database

Related Posts

[FIXED] javascript – How can I run multiple commands in package.json scripts? Android
[FIXED] java – How to Remove Small Objects from Image after Segmentation Android
[FIXED] How to move the word cursor to a y position on the Android EditText text? Android
[FIXED] kotlin – How to create signed URL to fetch private content from cloud front in Android Android
[FIXED] android – Install-time dynamic delivery of feature module based on user’s country Android
[FIXED] android – java.lang.IllegalStateException: Default FirebaseApp is not initialized in this process. Make sure to call FirebaseApp.initializeApp(Context) first Android

Archives

  • March 2023
  • February 2023
  • January 2023
  • December 2022
  • November 2022
  • October 2022
  • September 2022

Categories

  • ¿Cómo
  • ¿Cuál
  • ¿Cuándo
  • ¿Cuántas
  • ¿Cuánto
  • ¿Qué
  • Android
  • Are
  • At
  • C'est
  • Can
  • Comment
  • Did
  • Do
  • Does
  • Est-ce
  • Est-il
  • For
  • Has
  • Hat
  • How
  • In
  • Is
  • Ist
  • Kann
  • Où
  • Pourquoi
  • Quand
  • Quel
  • Quelle
  • Quelles
  • Quels
  • Qui
  • Should
  • Sind
  • Sollte
  • Uncategorized
  • Wann
  • Warum
  • Was
  • Welche
  • Welchen
  • Welcher
  • Welches
  • Were
  • What
  • What's
  • When
  • Where
  • Which
  • Who
  • Who's
  • Why
  • Wie
  • Will
  • Wird
  • Wo
  • Woher
  • you can create a selvedge edge: You can make the edges of garter stitch more smooth by slipping the first stitch of every row.2022-02-04
  • you really only need to know two patterns: garter stitch

Recent Posts

  • Can VPN be traced by police?
  • Where were Kaiser-Frazer cars built?
  • How do you make gold rose gold paint?
  • What are the newest type of dentures?
  • Can you wear joggers as dress pants?

Recent Comments

No comments to show.

Copyright © 2023 Snappy1.

Powered by PressBook Grid Dark theme