Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7590297
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T20:21:58+00:00 2026-05-30T20:21:58+00:00

When an activity is created for the first time then system calls the OnContentChanged()

  • 0

When an activity is created for the first time then system calls the OnContentChanged() method as the first method and last call by system is the OnDetachedFromWindow() method when an activity is killed, but android docs says entire lifetime of an Activity happens between OnCreate() and OnDestroy(). Why? Please help me in understanding difference between these methods.

Code:

import android.app.Activity;
import android.content.res.Configuration;
import android.os.Bundle;
import android.widget.Toast;

public class ActivitylifecycleActivity extends Activity {
    /** Called when the activity is first created. */

    @Override
    public void onContentChanged() {
        super.onContentChanged();   
        Toast.makeText(getApplicationContext(),"1. onContentChanged()", Toast.LENGTH_SHORT).show();
    }

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
        Toast.makeText(getApplicationContext(),"2. onCreate()", Toast.LENGTH_SHORT).show();
    }

    @Override
    public void onStart() {
        super.onStart();
        Toast.makeText(getApplicationContext(),"3. onStart()", Toast.LENGTH_SHORT).show();
    }

    @Override
    public void onRestoreInstanceState(Bundle restoreInstanceState) {
        Toast.makeText(getApplicationContext(),"4. onRestoreinstaneState()", Toast.LENGTH_SHORT).show();
        super.onRestoreInstanceState(restoreInstanceState);
    }

    @Override
    public void onRestart() {
        super.onRestart();
        Toast.makeText(getApplicationContext(),"5. onRestart()", Toast.LENGTH_SHORT).show();
    }

    @Override
    protected void onPostCreate(Bundle onpostcrete) {
        super.onPostCreate(onpostcrete);
        Toast.makeText(getApplicationContext(),"6. onPostCreate()", Toast.LENGTH_SHORT).show();
    }

    @Override
    public void onResume() {
        super.onResume();
        Toast.makeText(getApplicationContext(),"7. onResume()", Toast.LENGTH_SHORT).show();
    }

    @Override
    protected void onPostResume() {
        super.onPostResume();
        Toast.makeText(getApplicationContext(),"8. onPostResume()", Toast.LENGTH_SHORT).show();
    }

    @Override
    public void onAttachedToWindow() {
        super.onAttachedToWindow();
        Toast.makeText(getApplicationContext(),"9. onAttachedToWindow()", Toast.LENGTH_SHORT).show();
    }

    @Override
    public void onWindowFocusChanged(boolean bo) {
        super.onWindowFocusChanged(true);
        Toast.makeText(getApplicationContext(),"10. onWindowFocusChanged()", Toast.LENGTH_SHORT).show();
    }

    @Override
    public void onUserLeaveHint() {
        super.onUserLeaveHint();
        Toast.makeText(getApplicationContext(),"11. onUserLeaveHint()", Toast.LENGTH_SHORT).show();
    }

    @Override
    public void onUserInteraction() {
        super.onUserInteraction();
        ii=0;
        Toast.makeText(getApplicationContext(),"12. onUserInteraction()", Toast.LENGTH_SHORT).show();
    }

    @Override
    public void onSaveInstanceState(Bundle savedInstanceState) {
        super.onSaveInstanceState(savedInstanceState);
        Toast.makeText(getApplicationContext(),"13. onSaveInstanceState()", Toast.LENGTH_SHORT).show();
    }

    @Override
    public void onPause() {
        super.onPause();
        Toast.makeText(getApplicationContext(),"14. onPause()", Toast.LENGTH_SHORT).show();
    }

    @Override
    public void onStop() {
        super.onStop();
        Toast.makeText(getApplicationContext(),"15. onStop()", Toast.LENGTH_SHORT).show();
    }

    @Override
    public void onDestroy() {
        super.onDestroy();
        Toast.makeText(getApplicationContext(),"16. onDestroy()", Toast.LENGTH_SHORT).show();
    }

    @Override
    public void onDetachedFromWindow() {
        super.onDetachedFromWindow();
        Toast.makeText(getApplicationContext(),"17. onDetachedFromWindow()", Toast.LENGTH_SHORT).show();
    }

    @Override
    public void onConfigurationChanged(Configuration newConfig) {
        super.onConfigurationChanged(newConfig);
        Toast.makeText(getApplicationContext(),"18. onConfigurationChanged()", Toast.LENGTH_SHORT).show();
    }

    @Override
    public boolean onSearchRequested() {
        super.onSearchRequested();
        Toast.makeText(getApplicationContext(),"19. onSearchRequested()", Toast.LENGTH_SHORT).show();
        return false;
    }
}

In this code, onContentChanged() is called before onCreate() method and onDetachedFromWindow() is called after onDestroy(). Why?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-30T20:22:00+00:00Added an answer on May 30, 2026 at 8:22 pm

    onCreate():

    When an activity starts its life onCreate() is called. It is called only once in the lifecycle of an activity.

    onDestroy():

    onDestroy() is called when an activity finishes its life cycle. It is also called once in the lifecycle of an activity.

    onContentChanged():

    This hook is called whenever the content view of the screen changes (due to a call to Window.setContentView or Window.addContentView). For example you add new view to activity or want to refresh the list by calling notifyDataSetChanged().

    onDetachedFromWindow():

    Called when the main window associated with the activity has been detached from the window manager. For example, it is called when the current Activity goes into background or another activity came infront of current activity.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

My app for some reason fails the first time it opens, but then opens
What I want is that when Activity starts first time, it first checks if
I created an activity which holds 3 custom components (defined in xml). 2 components
I have created an activity which sends a number of notifications to status bar.
i have created a workflow activity that do give the item creater of a
I have created a custom workflow activity that copies attachments from a case to
I created and binded a service in an activity and I would like to
I called my main activity Main, and Eclipse created Main.java and res/layout/main.xml for the
The main activity includes some variables with set values. I created a sub-activity with
In my activity, I create a Bitmap object and then I need to launch

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.