Activity & Intents 2


 

  1. Activity Life Cycle
  2. Explicit Intent
  3. Implicit Intent
  4. Activity Forwarding
  5. Activity For Result
  6. Intent with Values Passing
  7. Intent with Values Passing via Bundle
  8. Screen Orientation

 

1. Activity Life Cycle

Step 1 : Select File -> New -> Project -> Android Application Project. Fill the forms, create “Blank Activity” and click “Finish” button.

Step 2 : Open res -> layout -> activity_main.xml and add following code :

Step 3 : Open src -> package -> MainActivity.java and add following code :

Step 4 : Open AndroidManifest.xml and add following code :

ScreenShot:

activity_life activity_life2 activity_life3

activity_life4 activity_life5 activity_life6

 

Download SourceCode

 

 

 

2. Explicit Intent

Step 1 : Select File -> New -> Project -> Android Application Project. Fill the forms, create “Blank Activity” and click “Finish” button.

Step 2 : Open res -> layout -> activity_main.xml and add following code :

Step 3 : Open src -> package -> MainActivity.java and add following code :

Step 4 : Open src -> package -> TargetActivity.java and add following code :

Step 5 : Open AndroidManifest.xml and add following code :

ScreenShot:

explicit explicit2

 

Download SourceCode

 

 

3. Implicit Intent

Step 1 : Select File -> New -> Project -> Android Application Project. Fill the forms, create “Blank Activity” and click “Finish” button.

Step 2 : Open res -> layout -> activity_main.xml and add following code :

Step 3 : Open src -> package -> MainActivity.java and add following code :

Step 4 : Open AndroidManifest.xml and add following code :

ScreenShot:

 implicit implicit2

Download SourceCode

 

4. Activity Forwarding

Step 1 : Select File -> New -> Project -> Android Application Project. Fill the forms, create “Blank Activity” and click “Finish” button.

Step 2 : Open res -> layout -> activity_main.xml and add following code :

Step 3 : Open src -> package -> MainActivity.java and add following code :

Step 4 : Open src -> package -> Create new class, ForwardingTarget.java and add following code :

Step 5 : Open AndroidManifest.xml and add following code :

ScreenShot:

activity_fwd activity_fwd2

Download SourceCode

 

5. Activity For Result

Step 1 : Select File -> New -> Project -> Android Application Project. Fill the forms, create “Blank Activity” and click “Finish” button.

Step 2 : Open res -> layout -> activity_main.xml and add following code :

Step 3 : Open src -> package -> MainActivity.java and add following code :

Step 4 : Open res -> layout -> Create new message_layout.xml and add following code :

Step 5 : Open src -> package -> Create new MessageClass.java and add following code :

Step 6 : Open AndroidManifest.xml and add following code :

ScreenShots:

activity_result activity_result2 activity_result3

 

Download SourceCode

 

 

6. Intent with Values Passing

Step 1 : Select File -> New -> Project -> Android Application Project. Fill the forms, create “Blank Activity” and click “Finish” button.

Step 2 : Open res -> layout -> activity_main.xml and add following code :

Step 3 : Open src -> package -> MainActivity.java and add following code :

Step 4 : Open src -> package -> Create new class, SecondActivity.java and add following code :

Step 5 : Open AndroidManifest.xml and add following code :

 

ScreenShot:

intent_values1 intent_values2

Download SourceCode

 

7. Intent with Values Passing via Bundle

Step 1 : Select File -> New -> Project -> Android Application Project. Fill the forms, create “Blank Activity” and click “Finish” button.

Step 2 : Open res -> layout -> activity_main.xml and add following code :

Step 3 : Open src -> package -> MainActivity.java and add following code :

Step 4 : Open src -> package -> Create new class, SecondActivity.java and add following code :

Step 5 : Open AndroidManifest.xml and add following code :

ScreenShot:

intent_bundle intent_bundle3 intent_bundle2

 

8. Screen Orientation

Step 1 : Select File -> New -> Project -> Android Application Project. Fill the forms, create “Blank Activity” and click “Finish” button.

Step 2 : Open res -> layout -> activity_main.xml and add following code :

Step 3 : Open src -> package -> MainActivity.java and add following code :

Step 4 : Open AndroidManifest.xml and add following code :

ScreenShot:

screenorien screenorien2 screenorien3

Download_button

 

 

  • great tutorial thanks a lot for your effort

    • Onedevapp

      Thanks sharan.