Activity and Intent Part 1
Assalamu’alaikum,
Activity is an application component that represents one window that typically fills the screen, like a page.
To Create an Activity, you can click File → New → Activity → Empty Activity.
When you create a new activity, there have 2 items and 1 line code that generated:
1. Layout items (activity_main2.xml)
2. Function items (Main2Activity.java)
3. Properties in (AndroidManifest.xml)
Here is the line code inside AndroidManifest.xml :
Okay, after the new activity or new page is created, you can navigate the first page to another page with Intent, so lets code for the navigation with intent:
- Create new instance of intent: Intent activityname = new Intent(SourcePage.this, DestinationPage.class)
- Apply the navigation and changing the activity with startActivity(activityname)
- This is the real implementation code:
When you navigate from source activity to another activity or page, you can bring the data too using put extra and receive the data in destination activity or page.
Sending the data from source activity:
Receive the data in destination activity:
Okay, well this is the basis of navigation and passing the data between two activities, next we will continue with part two.
Wassalamu’alaikum.