Drop Down MenusCSS Drop Down MenuPure CSS Dropdown Menu

Monday, 4 April 2016

What is Activity


An activity represents a single screen with a user interface just like window or frame of Java.Android activity is the subclass of ContextThemeWrapper class

Activity lifecycle

Activity is containing many method that use in development of android project.



onCreate :This is the first callback and called when the activity is first created

onStart :This method called when activity is becoming visible to the user.

onResume :This method called when activity will start interacting with the user.

onPause :
The paused activity does not receive user input and cannot execute any code and called when the current activity is being paused and the previous activity is being resumed.

onStop : This method called when activity is no longer visible to the user.

onRestart :This method called after your activity is stopped, prior to start.

onDestroy :This callback is called when the activity restarts after stopping it.

See below example how to use this methods..

package com.samset.activitysample;  
import android.os.Bundle;  
import android.app.Activity;  
import android.util.Log;  
import android.view.Menu;  

public class MainActivity extends Activity {  
 private String TAG="ActivitySample";
    protected void onCreate(Bundle savedInstanceState) {  
        Log.d(TAG,"onCreate method  invoked");  
    protected void onStart() {  
         Log.d(TAG,"onStart method  invoked");  
    protected void onResume() {  
         Log.d(TAG,"onResume method  invoked");  
    protected void onPause() {  
         Log.d(TAG,"onPause method  invoked");  
  protected void onStop() {  
         Log.d(TAG,"onStop method  invoked");  
    protected void onRestart() {  
         Log.d(TAG,"onRestart method  invoked");  
    protected void onDestroy() {  
         Log.d(TAG,"onDestroy method invoked");  

I hope this is very helps you
Thank you                                                                                                                                         

No comments:

Post a Comment