Java Android App Development Course, Creating KakaoTalk Notifications

In this course, we will develop an Android app using Java and implement the functionality to send notifications via KakaoTalk.
We plan to complete a feature that sends notifications to users when specific events occur using the KakaoTalk API.
This process will be explained based on Android Studio, and basic Android development knowledge is required.

Prerequisites

  • Installation and setup of Java and Android SDK
  • Installation of Android Studio
  • Creation of a KakaoTalk developer account and app
  • Verification of API Key and Secret Key

1. Android Studio Project Setup

Open Android Studio and create a new project. Select “Empty Activity” and complete the basic configuration before creating the project.

1.1 Gradle Setup

Next, open the build.gradle file of the app module and add the necessary libraries. We will be using Retrofit2 and Gson to utilize the KakaoTalk API.

dependencies {
    implementation 'com.squareup.retrofit2:retrofit:2.9.0'
    implementation 'com.squareup.retrofit2:converter-gson:2.9.0'
}

2. KakaoTalk API Integration

Create an application in the KakaoTalk Developer Center and verify the API Key. This key will be needed for future API calls.

2.1 Retrofit Setup

Add configuration to communicate with the API using Retrofit. Create a Retrofit instance and set up the necessary API interface.

public interface KakaoApi {
    @FormUrlEncoded
    @POST("/v2/api/talk/memo/default/send")
    Call sendMessage(@Header("Authorization") String token,
                                    @Field("template_object") String templateObject);
}

2.2 Implement Method for API Call

Implement a method to invoke the KakaoTalk API to send messages. OAuth authentication is required to authenticate the sender.

public class KakaoService {
    private static final String BASE_URL = "https://kapi.kakao.com";
    private KakaoApi kakaoApi;

    public KakaoService() {
        Retrofit retrofit = new Retrofit.Builder()
                .baseUrl(BASE_URL)
                .addConverterFactory(GsonConverterFactory.create())
                .build();
        kakaoApi = retrofit.create(KakaoApi.class);
    }

    public void sendKakaoTalk(String accessToken, String message) {
        String jsonTemplate = "{\"object_type\":\"text\",\"text\":\"" + message + "\"}";
        Call call = kakaoApi.sendMessage("Bearer " + accessToken, jsonTemplate);
        call.enqueue(new Callback() {
            @Override
            public void onResponse(Call call, Response response) {
                if (response.isSuccessful()) {
                    Log.d("KakaoTalk", "Message sent successfully");
                } else {
                    Log.d("KakaoTalk", "Message sending failed: " + response.message());
                }
            }

            @Override
            public void onFailure(Call call, Throwable t) {
                Log.d("KakaoTalk", "Error occurred: " + t.getMessage());
            }
        });
    }
}

3. User Interface Implementation

Create a simple UI to receive input from the user. Use EditText and Button to implement the functionality to input and send messages.

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical">

    <EditText
        android:id="@+id/messageInput"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:hint="Enter message"/>

    <Button
        android:id="@+id/sendButton"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="Send"/>

</LinearLayout>

3.1 Connect UI to Activity

Connect UI elements to the Activity to send a KakaoTalk message when the button is clicked.

public class MainActivity extends AppCompatActivity {
    private KakaoService kakaoService;
    private EditText messageInput;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        messageInput = findViewById(R.id.messageInput);
        Button sendButton = findViewById(R.id.sendButton);
        kakaoService = new KakaoService();

        sendButton.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                String message = messageInput.getText().toString();
                String accessToken = "YOUR_ACCESS_TOKEN";  // Enter the access token here
                kakaoService.sendKakaoTalk(accessToken, message);
            }
        });
    }
}

4. Testing and Deployment

Run the app, enter a message, and click the ‘Send’ button to check if the message is sent via KakaoTalk.
If there are no issues, you can distribute it as an APK file for use on other devices.

Through this course, you have been able to implement a feature that directly sends notifications from an Android app using the KakaoTalk API.
Future additional features may include considering automating the sending of KakaoTalk messages by catching user phone notifications.
Create an app that communicates with more users through these features!

Java Android App Development Course, Creating a KakaoTalk Password Verification Screen

Hello! In this tutorial, we will introduce how to develop Android apps using Java. Specifically, through a project that creates a password confirmation screen similar to KakaoTalk, you will learn various concepts of Android development. This project includes everything from basic UI composition to data validation and event handling, providing you with a near-real experience.

Project Overview

The password confirmation screen requires users to input a password and provides a feature to verify it. This is an essential function in many applications, playing an important role in user authentication and information protection. Through this project, you will learn the following skills:

  • Creating a new project in Android Studio
  • UI design through XML layout files
  • Connecting UI and logic using Java
  • Password validation and user feedback handling

1. Setting Up the Development Environment

The first thing you need to do for Android app development is to set up the development environment. Download and install Android Studio to establish a basic development environment. After installation, create a new project. Name the project ‘PasswordCheckApp’ and select the ‘Empty Activity’ template.

2. Configuring the XML Layout

After creating the project, modify the ‘activity_main.xml’ file located in the ‘res/layout’ folder to design the user interface (UI).

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:padding="16dp">

    <TextView
        android:id="@+id/textViewTitle"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="Password Confirmation"
        android:textSize="24sp"
        android:layout_centerHorizontal="true" 
        android:layout_marginBottom="24dp"/>

    <EditText
        android:id="@+id/editTextPassword"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:hint="Enter your password"
        android:inputType="textPassword"/>

    <Button
        android:id="@+id/buttonConfirm"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="Confirm"
        android:layout_below="@id/editTextPassword"
        android:layout_centerHorizontal="true"
        android:layout_marginTop="16dp"/>

    <TextView
        android:id="@+id/textViewResult"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_below="@id/buttonConfirm"
        android:layout_centerHorizontal="true"
        android:layout_marginTop="16dp"
        android:textSize="16sp"/>
</RelativeLayout>

The above XML code creates a title, a password input field, a confirm button, and a TextView to display the result on the screen. Users can enter their passwords and check the results using this layout.

3. Implementing the Main Activity

After configuring the XML layout, let’s connect the UI and logic in the Java file. Open the ‘MainActivity.java’ file and write the following code:

package com.example.passwordcheckapp;

import androidx.appcompat.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;
import android.widget.Toast;

public class MainActivity extends AppCompatActivity {

    private EditText editTextPassword;
    private Button buttonConfirm;
    private TextView textViewResult;

    private static final String CORRECT_PASSWORD = "mypassword"; // Correct password

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        editTextPassword = findViewById(R.id.editTextPassword);
        buttonConfirm = findViewById(R.id.buttonConfirm);
        textViewResult = findViewById(R.id.textViewResult);

        buttonConfirm.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                checkPassword();
            }
        });
    }

    private void checkPassword() {
        String inputPassword = editTextPassword.getText().toString();

        if (inputPassword.isEmpty()) {
            Toast.makeText(this, "Please enter your password.", Toast.LENGTH_SHORT).show();
            return;
        }

        if (inputPassword.equals(CORRECT_PASSWORD)) {
            textViewResult.setText("The password matches.");
        } else {
            textViewResult.setText("The password is incorrect.");
        }
    }
}

The above Java code implements a basic password verification logic. It compares the password entered by the user with the correct password and displays the result in the TextView. If the password is incorrect, the user is notified with a Toast message.

4. Running and Testing the Project

Once you have written the code, you can run the app on the Android Studio emulator or a real device. When the user enters the password and clicks the ‘Confirm’ button, it checks whether the password matches and displays the result on the screen.

5. Implementing Additional Features

The password confirmation screen provides basic functionality, but you can implement additional features to enhance the user experience. For example, you can add a feature to show or hide the password entered in the input field or implement a pattern lock method for password input.

Adding a Show/Hide Password Feature

Let’s add a feature that allows users to hide the password they entered. To do this, first, add an icon corresponding to the ‘EditText’, and implement a click event to show or hide the password.

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:padding="16dp">

    <TextView
        android:id="@+id/textViewTitle"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="Password Confirmation"
        android:textSize="24sp"
        android:layout_centerHorizontal="true"
        android:layout_marginBottom="24dp"/>

    <EditText
        android:id="@+id/editTextPassword"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:hint="Enter your password"
        android:inputType="textPassword"/>

    <ImageView
        android:id="@+id/imageViewTogglePassword"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_toRightOf="@id/editTextPassword"
        android:layout_marginStart="8dp"
        android:src="@drawable/ic_visibility_off"/>

    <Button
        android:id="@+id/buttonConfirm"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="Confirm"
        android:layout_below="@id/editTextPassword"
        android:layout_centerHorizontal="true"
        android:layout_marginTop="16dp"/>

    <TextView
        android:id="@+id/textViewResult"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_below="@id/buttonConfirm"
        android:layout_centerHorizontal="true"
        android:layout_marginTop="16dp"
        android:textSize="16sp"/>
</RelativeLayout>

You also need to modify the Java code to add the password visualization toggle function. Add the following code in ‘MainActivity.java’:

imageViewTogglePassword = findViewById(R.id.imageViewTogglePassword);

        imageViewTogglePassword.setOnClickListener(new View.OnClickListener() {
            boolean isPasswordVisible = false;

            @Override
            public void onClick(View v) {
                if (isPasswordVisible) {
                    editTextPassword.setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_PASSWORD);
                    imageViewTogglePassword.setImageResource(R.drawable.ic_visibility_off);
                } else {
                    editTextPassword.setInputType(InputType.TYPE_TEXT_VARIATION_VISIBLE_PASSWORD);
                    imageViewTogglePassword.setImageResource(R.drawable.ic_visibility);
                }
                isPasswordVisible = !isPasswordVisible;
                editTextPassword.setSelection(editTextPassword.length());
            }
        });

With the above code, we have set it up so that users can more conveniently enter their passwords. Now, clicking the icon will allow them to either show or hide the password.

Conclusion

Through this tutorial, you learned how to create a simple password confirmation screen using Java and Android. Since you learned about basic UI composition and handling user interactions, this will provide a good opportunity to expand the app by adding more complex features in the future. After practice, think about additional features and improvements, and trying them out is also a good way to learn.

Additionally, check out more resources and communities related to Android development, and challenge yourself with various projects. I hope this will help you in your Android development journey!

Inquiries

Please leave any inquiries regarding this tutorial in the comments. Active feedback is a great help to us!

Java Android App Development Course, Creating an App that Interacts with Camera and Gallery

In Android app development, the integration of camera and gallery features is very consumer-friendly and is an essential functionality for many apps. In this tutorial, we will develop a simple camera and gallery integration app using Java. This app will allow users to take photos or select images from the gallery. Now, let’s look at the step-by-step process required to create this app.

1. Environment Setup

Install Android Studio and create a new project. When creating the project, select “Empty Activity” or “Basic Activity.” Choose Java as the language and click “Finish” to complete the project creation.

2. Request Necessary Permissions

You need to add the required permissions to the AndroidManifest.xml file to run the camera and gallery functions.


    <manifest xmlns:android="http://schemas.android.com/apk/res/android"
              package="com.example.camera_gallery">
        <uses-permission android:name="android.permission.CAMERA"/>
        <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>
        <application
            android:allowBackup="true"
            android:icon="@mipmap/ic_launcher"
            android:label="@string/app_name"
            android:roundIcon="@mipmap/ic_launcher_round"
            android:supportsRtl="true"
            android:theme="@style/Theme.AppCompat.Light.NoActionBar">
            <activity android:name=".MainActivity">
                <intent-filter>
                    <action android:name="android.intent.action.MAIN"/>
                    <category android:name="android.intent.category.LAUNCHER"/>
                </intent-filter>
            </activity>
        </application>
    </manifest>
    

3. UI Design

Design a simple user interface in the activity_main.xml file. Add two buttons and an ImageView to display the image.


    <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
        android:layout_width="match_parent"
        android:layout_height="match_parent">
    
        <Button
            android:id="@+id/button_camera"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="Take a Photo with Camera" 
            android:layout_centerHorizontal="true"
            android:layout_marginTop="50dp"/>
    
        <Button
            android:id="@+id/button_gallery"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="Select from Gallery" 
            android:layout_below="@id/button_camera"
            android:layout_centerHorizontal="true"
            android:layout_marginTop="20dp"/>
    
        <ImageView
            android:id="@+id/image_view"
            android:layout_width="match_parent"
            android:layout_height="300dp"
            android:layout_below="@id/button_gallery"
            android:layout_marginTop="20dp"
            android:scaleType="centerCrop"/>
    
    </RelativeLayout>
    

4. Implement MainActivity.java

Now, write the MainActivity.java file to call the camera or gallery app based on button click events. First, set the click listeners for the buttons and implement the respective functionalities.


    package com.example.camera_gallery;

    import android.content.Intent;
    import android.graphics.Bitmap;
    import android.net.Uri;
    import android.os.Bundle;
    import android.provider.MediaStore;
    import android.view.View;
    import android.widget.Button;
    import android.widget.ImageView;
    import androidx.annotation.Nullable;
    import androidx.appcompat.app.AppCompatActivity;

    public class MainActivity extends AppCompatActivity {
        private static final int CAMERA_REQUEST = 100;
        private static final int GALLERY_REQUEST = 200;
        
        private ImageView imageView;

        @Override
        protected void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);
            setContentView(R.layout.activity_main);

            imageView = findViewById(R.id.image_view);
            Button buttonCamera = findViewById(R.id.button_camera);
            Button buttonGallery = findViewById(R.id.button_gallery);

            buttonCamera.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View view) {
                    Intent cameraIntent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
                    startActivityForResult(cameraIntent, CAMERA_REQUEST);
                }
            });

            buttonGallery.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View view) {
                    Intent galleryIntent = new Intent(Intent.ACTION_PICK, MediaStore.Images.Media.EXTERNAL_CONTENT_URI);
                    startActivityForResult(galleryIntent, GALLERY_REQUEST);
                }
            });
        }

        @Override
        protected void onActivityResult(int requestCode, int resultCode, @Nullable Intent data) {
            super.onActivityResult(requestCode, resultCode, data);
            if (resultCode == RESULT_OK) {
                if (requestCode == CAMERA_REQUEST) {
                    Bundle extras = data.getExtras();
                    Bitmap imageBitmap = (Bitmap) extras.get("data");
                    imageView.setImageBitmap(imageBitmap);
                } else if (requestCode == GALLERY_REQUEST) {
                    Uri selectedImageUri = data.getData();
                    imageView.setImageURI(selectedImageUri);
                }
            }
        }
    }
    

5. Run and Test the App

Now that you’ve written all the code, run the app to test it. When you run the app on an emulator or a real smartphone, pressing the “Take a Photo with Camera” button will open the camera app, allowing you to take a photo and set it as the preview image. Pressing the “Select from Gallery” button allows you to choose an image from the gallery app and display it as a preview.

6. Conclusion

In this tutorial, we developed a simple Android app that integrates the camera and gallery using Java. This functionality is a fundamental skill that can be used in various Android apps, and you can build upon this to add more complex features tailored to individual needs. It is recommended to continue expanding on these foundational elements as you progress in Android development.

7. Additional Resources

Java Android App Development Course, Conditional Statements and Loops

Android application development fundamentally relies on the Java programming language. Conditional statements and loops are the most basic structures in programming, and it is difficult to implement app functionality without them. In this post, I will provide a detailed explanation of conditional statements and loops using Java, along with example code to demonstrate their use.

1. Understanding Conditional Statements

Conditional statements are used to control the flow of a program based on whether a particular condition is true or false. In Java, the primary conditional statements used are if, else, and switch.

1.1 if Statement

The most basic conditional statement is the if statement. This statement executes a specific block of code when the given condition is true.

if (condition) {
    // Code to be executed if the condition is true
}

1.2 else Statement

The else statement, used in conjunction with the if statement, defines the code that will be executed if the specified condition is false.

if (condition) {
    // Executed if true
} else {
    // Executed if false
}

1.3 else if Statement

When you need to check multiple conditions, you use else if.

if (condition1) {
    // Executed if condition1 is true
} else if (condition2) {
    // Executed if condition2 is true
} else {
    // Executed if all above conditions are false
}

1.4 switch Statement

The switch statement is useful when you need to select one from multiple conditions. It allows for cleaner writing and is useful when dealing with complex conditions.

switch (variable) {
    case value1:
        // Executed if value1
        break;
    case value2:
        // Executed if value2
        break;
    default:
        // Executed if no conditions match
}

2. Understanding Loops

Loops help execute a specific block of code multiple times. In Java, the main types of loops are for, while, and do while.

2.1 for Statement

The for loop is useful when the number of iterations is clear. It repeats based on an initial value, a condition, and an increment expression.

for (initialization; condition; increment) {
    // Code to be executed in loop
}

2.2 while Statement

The while loop repeats as long as the given condition is true.

while (condition) {
    // Code to be executed in loop
}

2.3 do while Statement

The do while loop executes at least once and then checks the condition for further repetition.

do {
    // Code to be executed
} while (condition);

3. Example Utilizing Conditional Statements and Loops

Now, let’s explore how conditional statements and loops are used in a simple Android app through an example.

3.1 Example: User Input-Based Calculator App

We will create a calculator app that outputs results based on two numbers and an operator input by the user. Here, we will use both conditional statements and loops.

package com.example.simplecalculator;

import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;
import androidx.appcompat.app.AppCompatActivity;

public class MainActivity extends AppCompatActivity {

    private EditText number1EditText, number2EditText;
    private TextView resultTextView;
    private Button calculateButton;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        number1EditText = findViewById(R.id.number1);
        number2EditText = findViewById(R.id.number2);
        resultTextView = findViewById(R.id.result);
        calculateButton = findViewById(R.id.calculateButton);

        calculateButton.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                calculate();
            }
        });
    }

    private void calculate() {
        String number1String = number1EditText.getText().toString();
        String number2String = number2EditText.getText().toString();
        if (number1String.isEmpty() || number2String.isEmpty()) {
            resultTextView.setText("Please fill in all input fields.");
            return;
        }

        int number1 = Integer.parseInt(number1String);
        int number2 = Integer.parseInt(number2String);
        String operator = ""; // TODO: Add operator variable here

        switch (operator) {
            case "+":
                resultTextView.setText("Result: " + (number1 + number2));
                break;
            case "-":
                resultTextView.setText("Result: " + (number1 - number2));
                break;
            case "*":
                resultTextView.setText("Result: " + (number1 * number2));
                break;
            case "/":
                if (number2 == 0) {
                    resultTextView.setText("Cannot divide by zero.");
                } else {
                    resultTextView.setText("Result: " + (number1 / number2));
                }
                break;
            default:
                resultTextView.setText("Please select a valid operator.");
                break;
        }
    }
}

4. Detailed Explanation of the Example

The code above is a simple calculator app where the user inputs two numbers and selects an operator to calculate the result.

4.1 User Input Handling

To receive two numbers from the user, we use EditText widgets. We use the getText().toString() method to retrieve the value entered by the user.

4.2 Using Conditional Statements

To check if the input values are empty, we use an if statement to prompt the user to fill in all input fields.

4.3 Using switch Statement

To perform calculations based on the operator selected by the user, we use a switch statement. Each case executes the corresponding operation, and the result is displayed in the TextView.

4.4 Exception Handling

For division operations, additional conditions are checked to prevent division by zero.

5. Conclusion

Conditional statements and loops are fundamental and crucial concepts in Java Android app development. If you have learned how to use them through the above example, you can build upon that knowledge to implement more complex logic. Appropriately using conditional statements and loops in various scenarios will help you develop useful applications.

6. Next Steps

Having mastered conditional statements and loops, the next step is to learn about data structures and algorithms. Use lists, maps, etc., to extend the functionality of your app. Additionally, you should also learn about event handling to make interactions with the user interface even richer.

Did you find this post useful? Please leave your comments!

Java Android App Development Course, Creating Your First App

Android app development is a crucial field in modern software development. Android is one of the most widely used mobile operating systems worldwide, and various apps are being developed for it. In this course, we will take a detailed look at the process of creating our first Android app using the Java language.

1. Setting Up the Android App Development Environment

To start Android app development, you first need to set up the development environment. Android Studio is the officially supported IDE by Google and is the most commonly used tool for Android app development.

1.1 Installing Android Studio

The process of downloading and installing Android Studio is straightforward. Follow these steps:

  1. Visit the official Android Studio website.
  2. Download the installation file suitable for your operating system.
  3. Once the download is complete, run the installation file and follow the instructions to complete the installation.
  4. After the installation is complete, launch Android Studio and install the required SDK (Software Development Kit).

1.2 Configuring Android Studio

When you first run Android Studio, you will need to perform some configurations. In the initial setup wizard, specify the SDK path and proceed to install any additional necessary features. Once all settings are completed, you will be able to see the main screen of Android Studio.

2. Creating Your First Android App

Now, let’s create our first app. The app we will create is a simple “Hello World” app. This app has the functionality to display the text “Hello World” on the screen.

2.1 Creating a New Project

The method to create a new project in Android Studio is as follows:

  1. After launching Android Studio, select ‘Start a new Android Studio project’.
  2. Select ‘Phone and Tablet’, choose ‘Empty Activity’, and then click ‘Next’.
  3. Enter the project name. For example, type “HelloWorldApp” and set the package name as well.
  4. Select the save location, choose Java as the language, and then select the minimum SDK version. The recommended version is Android 5.0 (API 21), and click ‘Finish’.

2.2 Adding Layout

Once the project is created, open the ‘app/res/layout/activity_main.xml’ file to define the basic layout. This file is where you set up the app’s UI (User Interface). Modify it as follows to add the basic text:


<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent">

    <TextView
        android:id="@+id/textView"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="Hello World!"
        android:textSize="30sp"
        android:layout_centerInParent="true"/>

</RelativeLayout>

2.3 Writing Java Code

Now, navigate to the ‘MainActivity.java’ file and add the code as follows. This file controls the application’s logic.


package com.example.helloworldapp;

import android.os.Bundle;
import androidx.appcompat.app.AppCompatActivity;

public class MainActivity extends AppCompatActivity {
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
    }
}

2.4 Running the App

Now you are ready to run the app. Click the run button (green arrow) on the top toolbar of Android Studio to select an emulator or connect a physical device to run it. You can easily test the app.

3. Deploying the App

If the app is fully functional, you are now ready to deploy it. The method for deploying an Android app is as follows:

  1. Select ‘Build’ from the top menu in Android Studio, then choose ‘Build Bundle(s)/APK(s)’ > ‘Build APK(s)’.
  2. The APK file will be built, and once the build is complete, a notification will appear where you can confirm the path of the APK file.
  3. You can use this APK file to install on a physical device or register it on the Google Play Store to deploy.

4. Future Learning Directions

In this course, we have looked at the basic steps to create a simple Android app using Java. However, Android development does not end here. For the next steps, consider exploring the following topics:

  • Using various UI components (buttons, images, lists, etc.)
  • Data storage (SQLite, SharedPreferences, etc.)
  • Network communication (API calls and JSON parsing)
  • Understanding Android Architecture Components (LiveData, ViewModel, etc.)

5. Conclusion

Android app development is a field with many possibilities. Even beginners can easily create their first app through Java, and by adding various features, it can evolve into a more complex app. I hope this course has helped you lay the groundwork for Android app development.

Wishing you the best on your future development journey!