Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Call method on activity load, Android [closed]

I want to call a method as soon as the activity has loaded. The method is a public void. Any help would be appreciated

like image 792
Hamzah Malik Avatar asked Nov 27 '22 05:11

Hamzah Malik


1 Answers

You can use the following method

You can call your method in between any one of them on Activity startup all these are called where as onResume is called every time activity resumes it is well explained in ActivityLifeCycle Diagram

@Override
public void onCreate(Bundle savedInstanceState)
{
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_splash);   

}


@Override
protected void onStart()
{   
    // TODO Auto-generated method stub
    super.onStart();
}


@Override
protected void onResume()
{   
    // TODO Auto-generated method stub
    super.onResume();
}

You can learn more from here

You can learn more from ActivityLifeCycle

or follow this ActivityLifeCycle

enter image description here

like image 191
Trikaldarshiii Avatar answered Dec 05 '22 14:12

Trikaldarshiii