Created
August 12, 2018 16:43
-
-
Save shubhamnikam/a9c1342559717be486082e7f2a0e2bcd to your computer and use it in GitHub Desktop.
Simple activity lifecycle example using Android log
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.theappnerds.shubham.activitylifecycle; | |
import android.os.Bundle; | |
import android.support.v7.app.AppCompatActivity; | |
import android.util.Log; | |
import com.theappnerds.activitylifecycle.R; | |
public class MainActivity extends AppCompatActivity { | |
String tag = "ActivityLifecyleStates"; | |
@Override | |
protected void onCreate(Bundle savedInstanceState) { | |
super.onCreate(savedInstanceState); | |
setContentView(R.layout.activity_main); | |
Log.d(tag, "onCreate() event"); | |
} | |
public void onStart() { | |
super.onStart(); | |
Log.d(tag, "onStart() event"); | |
} | |
public void onRestart() { | |
super.onRestart(); | |
Log.d(tag, "onRestart() event"); | |
} | |
public void onResume() { | |
super.onResume(); | |
Log.d(tag, "onResume() event"); | |
} | |
public void onPause() { | |
super.onPause(); | |
Log.d(tag, "onPause() event"); | |
} | |
public void onStop() { | |
super.onStop(); | |
Log.d(tag, "onStop() event"); | |
} | |
public void onDestroy() { | |
super.onDestroy(); | |
Log.d(tag, "onDestroy() event"); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment