E
E
Erimaru2017-05-27 16:54:14
Android
Erimaru, 2017-05-27 16:54:14

How to interact with Activity life cycles?

Hello. I just recently started learning android development and there is one question that I can't find an answer to. I have read a lot about the activity life cycle, but how to use them is not described anywhere. Describes mostly examples with Toasts. For example, in my application there are many different activities, and I need that when I click "back" and go back, the old activity is removed from memory. The loop is "onPause() → onStop() → onDestroy()", but how to write it?
Thank you.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
7
7365656c65, 2017-05-27
@73656c6565

Redefine them:

@Override
    protected void onDestroy(){
        super.onDestroy();
        Log.d(TAG, "onDestroy");
    }
    @Override
    protected void onStop(){
        super.onStop();
        Log.d(TAG, "onStop");
    }
    @Override
    protected void onStart(){
        super.onStart();
        Log.d(TAG, "onStart");
    }
    @Override
    protected void onPause(){
        super.onPause();
        Log.d(TAG, "onPause");
    }
    @Override
    protected void onResume(){
        super.onResume();
        Log.d(TAG, "onResume");
    }

And read the link .

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question