Kickstart Your First Project
Breathe In…Hold
Welcome to Topic 5 of the Android Development course.
By now, all your development tools are ready and your fingers must have started to twitch with excitement.
Now you’re ready to start cooking with Android.
…And Launch!
So, let us proceed to write a simple Android Application which will print "Hello World!".
First things first: Start Android Studio. You should see a screen that looks similar to the one shown above.
If you haven’t set up your development environment yet, revisit Topic 4.
If you already have…Well, it is time to say, “Hello.”
Choosing the Activity
When you next install Android, you will be required to select the activity, that is, what do you want your app to do?
You will see the various default layouts for Applications from which select Empty Activity, and click Next.
Which of the following activities did we choose to create the Hello App in this topic?
Select the right answer
A. Blank Activity
B. Empty Activity v
C. Null Activity
D. No Activity
Configuring the Project
Now, we configure our project, by:
Building Your App
Now, the project will be built and you will be able to design your app. The screen will look like the one shown here.
Open the res node and double-click activity_main.xml.
Which node nests the activity_main.xml in Android Studio?
Select the right answer
A. res v
B. java
C. manifest
D. design
Layout and Blueprint
Here is the layout of the app. You can adjust the size of the surrounding windows to see the preview better.
You can also see the blueprint for the layout shown in blue.
You can update the view to show just the layout. Just go to the Surface tab and select Design.
The Activity and Layout
Your app comprises two elements:
1. Main activity
2. Layout
You can view the layout in XML by selecting the Text tab.
Which of the following are the key elements of an app?
Select one or more answers
A. Main activity v
B. Layout v
C. Add-ons
D. Users
Main Activity XML
Now, you can see the XML layout.
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Hello World!"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="parent" />
</androidx.constraintlayout.widget.ConstraintLayout>
Don't worry, these are auto created when you design the layout.
Ready to Run the App
You’re almost ready to run your Hello Android application!
You can run your apps in one of two ways before actually publishing them. You can run the app either on:
A device simulator called the Android Emulator; or
Your personal device.
For now, let’s run Hello World on the Emulator. We will try publishing the app on a real machine in a later topic.
Kickstart Your First Project