Life cycle of an android

I want the view animation to appear after my activity has resumed, but I can't manage to catch the time after loading all views and starting the animation before loading all views (before the animation transitions). i tried using onDraw, onWindowFocusChange, onResume, i found onDraw is the last method in the view lifecycle, but i still saw the animation start before the user sees all views

+3


source to share


3 answers


Consider using a Fragment instead of a Fragment view if the views do not have a lifecycle. The life cycle is related to their activities, where they are embedded.

See also: What is the advantage of using Fragments in Android over Views?

Edit:



Try to delay the animation:

new Handler().post(new Runnable() {
    @Override
    public void run() {
        // Start your animation here.
    }
});

      

+1


source


You can create a burst of activity. In this splash activity, you can show your animation.

How do I create a splash screen?



also if you need to calculate sth while it animates, use a stream to calculate and send it to your main activity.

How to pass data between activities in an Android app?

0


source


This shows the Android lifecycle and Android View lifecycle on my device (Sony Z1 Compact)

Start an Activity
    Activity: onCreate
    Activity: onStart
    Activity: onResume
    View: onAttachedToWindow
    View: onWindowFocusChanged true
    # Running
    Activity: onPause
    View: onWindowFocusChanged false
    # Start to an Activity
    # Back from an Activity
    Activity: onResume
    View: onWindowFocusChanged true
    # Running
    View: onWindowFocusChanged false
    Activity: onPause
    Activity: onStop
    Activity: onDestroy
    View: onDetachedFromWindow

Turn Off Screen
    Activity: onCreate
    Activity: onStart
    Activity: onResume
    View: onAttachedToWindow
    View: onWindowFocusChanged true
    # Running
    Activity: onPause
    Activity: onStop
    View: onWindowFocusChanged false
    # Turn Off Screen
    # Turn On Screen
    Activity: onStart
    Activity: onResume
    View: onWindowFocusChanged true
    # Running
    View: onWindowFocusChanged false
    Activity: onPause
    Activity: onStop
    Activity: onDestroy
    View: onDetachedFromWindow

Switch Application
    Activity: onCreate
    Activity: onStart
    Activity: onResume
    View: onAttachedToWindow
    View: onWindowFocusChanged true
    # Running
    Activity: onPause
    View: onWindowFocusChanged false
    Activity: onStop
    # Switch to Application
    # Back from Application
    Activity: onStart
    Activity: onResume
    View: onWindowFocusChanged true
    # Running
    Activity: onPause
    View: onWindowFocusChanged false
    Activity: onStop
    Activity: onDestroy
    View: onDetachedFromWindow

      

0


source







All Articles