I want some view animation to occur after resuming my activity, but I can't succeed to catch the time after all the views loaded and the animation started before all the views loaded (before the animation transition). i tried to use onDraw, onWindowFocusChange, onResume, I discovered that onDraw is the last method on the life cycle of view but I still saw that the animation start before the user see the all the views
            Asked
            
        
        
            Active
            
        
            Viewed 1,353 times
        
    3
            
            
        - 
                    post some code of your `onCreate()` and when you start the animation. – Sagar Pilkhwal Sep 07 '14 at 12:07
- 
                    I start the animation on onDraw method – user3863927 Sep 08 '14 at 12:23
3 Answers
4
            
            
        Here is Android Activity lifecycle & Android View lifecycle tested 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 another Activity
    # Back from another 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
 
    
    
        Afrig Aminuddin
        
- 772
- 1
- 9
- 22
- 
                    This is very helpful, because it shows the View's actual lifecycle, not just the first half like most documentation I've found. Thank you. – Stephen M -on strike- Sep 04 '18 at 20:11
1
            
            
        Consider using a Fragment instead of a view as fragments unless views have a life cycle. The life cycle is bound to their Activity where they are embedded.
See also: What is the benefit of using Fragments in Android, rather than Views?
Edit:
Try starting your animation delayed:
new Handler().post(new Runnable() {
    @Override
    public void run() {
        // Start your animation here.
    }
});
 
    
    
        Community
        
- 1
- 1
 
    
    
        Lars Blumberg
        
- 19,326
- 11
- 90
- 127
- 
                    My view is already in a fragment, this is not relevant to my question at all. – user3863927 Sep 08 '14 at 08:42
- 
                    So why don't you then forward the Fragment lifecycle calls to your view? – Lars Blumberg Sep 08 '14 at 09:49
- 
                    because I see the animation after it started when I put my animation on onDraw() nethod – user3863927 Sep 08 '14 at 12:24
- 
                    
- 
                    
0
            
            
        You can create a splash activity. In this splash activity you can show your animation.
How do I make a splash screen?
also if you need to calculate sth while it shows animation, use a thread to calculate and send it to your main activity
How do I pass data between Activities in Android application?
- 
                    This has nothing to do with splash activity or with passing data between activities, I have an animation that I want to start the moment that the activity is visible to the user and the views are rendered. where ever I tried so far to put the start of the animation was too soon – user3863927 Sep 08 '14 at 08:42
 
    