Android Application Development
Android Application Development
Objectives:
Materials Needed:
o Computer with Windows 7 OS
o Android Studio
o Java Development Kit
Procedure:
After entered application name, it going to be called select the form factors your application
runs on, here need to specify Minimum SDK, in our tutorial, I have declared as API23: Android
6.0(Mashmallow) −
The next level of installation should contain selecting the activity to mobile, it specifies the
default layout for Applications.
At the final stage it’s going to be open development tool to write the application code.
Step 6: After Click on a virtual device icon, it going to be shown by default virtual devices
which are present on your SDK, or else need to create a virtual device by clicking Create new
Virtual device button
If your AVD is created successfully it means your environment is ready for Android application
development.
Before Writing a Hello word code, you must know about XML tags.To write hello word code,
you should redirect to App>res>layout>Activity_main.xml. Then To show hello word, we
need to call text view with layout ( about text view and layout, you must take references at
Relative Layout and Text View ).
B. Expand java. The application name, then click MainActivity.java as shown below
Step 3: Right click the button and choose “Go to XML”. Modify the android text: “Launch
Profile Activity”.
To the left of Android Studio, you will find Project Explorer. Right Click on the app from
the project explorer and select,
Let’s add some text to identify it as another Activity. We have added a TextView which displays
the text “Hello User”. Also, we added a Button which helps to go back to our Main Activity.
activity_profile.xml
<Button
android:id="@+id/bt_go_back"
android:layout_below="@+id/tv_message"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/activity_vertical_margin"
android:text="Go Back"
android:layout_centerHorizontal="true"
style="@style/Widget.AppCompat.Button.Colored"/>
</RelativeLayout>
Open MainActivity.java file and create a method which launches the Activity. Here I have
created a method launchActivity() which has Intent defined and startActivity() method is
called to launch Activity. Now we need to call this launchActivity() method when the button is
pressed, For that we need to attach an OnClickListener to that Button. It can be done by using
the setOnClickListener() method. In this, we call the launchActivity() method.
Now you want to Go back to Main Activity. Let’s do this. Similarly, attach an
OnClickListener to the Go Back button. Call the finish() method. The finish() is an Activity
method which destroys the Profile Activity and we will be back in Main Activity.
</manifest>
Let us try to click lock screen button on the Android emulator and it will generate following
events messages in LogCat window in android studio:
Next, let us again try to click Back button on the Android emulator and it will generate
following events messages in LogCat window in Android studio and this completes the
Activity Life Cycle for an Android Application.