Java Android App Development Course, Activity Control

In the Android platform, Activity is a key component that constitutes the user interface.
An activity can be viewed as a screen where the user can perform specific tasks and represents the basic building block of an Android application.

What is an Activity?

An activity is a screen that displays a specific task to the user. For example, screens where users can click buttons or
input information are all considered activities. Each activity exists independently and allows users
to perform various tasks by switching between multiple activities.

Activity Lifecycle

An activity has states such as creation, start, pause, resume, stop, and destruction, and these states are managed through
the activity’s lifecycle. Understanding the activity lifecycle is crucial for app development.

Lifecycle Methods

  • onCreate(): Called when the activity is first created. Initializes UI and performs setup tasks.
  • onStart(): Called when the activity is about to become visible to the user.
  • onResume(): Called when the activity starts interacting with the user.
  • onPause(): Called when another activity is about to start interacting with the user. Used to save important tasks.
  • onStop(): Called when the activity is no longer visible to the user.
  • onDestroy(): Called when the activity is finishing. Used to clean up remaining resources to prevent memory leaks.

Activity Example

Below is a sample code that creates a basic activity and implements lifecycle methods.
In this example, the current state will be displayed in a TextView.


public class MainActivity extends AppCompatActivity {
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        TextView textView = findViewById(R.id.textView);
        textView.setText("onCreate called");
    }

    @Override
    protected void onStart() {
        super.onStart();
        TextView textView = findViewById(R.id.textView);
        textView.setText("onStart called");
    }

    @Override
    protected void onResume() {
        super.onResume();
        TextView textView = findViewById(R.id.textView);
        textView.setText("onResume called");
    }

    @Override
    protected void onPause() {
        super.onPause();
        TextView textView = findViewById(R.id.textView);
        textView.setText("onPause called");
    }

    @Override
    protected void onStop() {
        super.onStop();
        TextView textView = findViewById(R.id.textView);
        textView.setText("onStop called");
    }

    @Override
    protected void onDestroy() {
        super.onDestroy();
        TextView textView = findViewById(R.id.textView);
        textView.setText("onDestroy called");
    }
}
    

Communication Between Intents and Activities

In Android, transitions between activities occur through Intents.
An intent is an object used to pass information from one activity to another or to call system components.

Intent Usage Example

Let’s look at sample code that creates two activities, where clicking a button in the first activity
transitions to the second activity.


// MainActivity.java
public class MainActivity extends AppCompatActivity {
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        Button button = findViewById(R.id.button);
        button.setOnClickListener(v -> {
            Intent intent = new Intent(MainActivity.this, SecondActivity.class);
            startActivity(intent);
        });
    }
}

// SecondActivity.java
public class SecondActivity extends AppCompatActivity {
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_second);
        TextView textView = findViewById(R.id.textView);
        textView.setText("This is the second activity.");
    }
}
    

Passing Data

When using intents, you can also pass data along. Let’s examine how to pass data via intents through
the following example.


// MainActivity.java (Adding data transfer)
public class MainActivity extends AppCompatActivity {
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        Button button = findViewById(R.id.button);
        button.setOnClickListener(v -> {
            Intent intent = new Intent(MainActivity.this, SecondActivity.class);
            intent.putExtra("message", "Hello, Second Activity");
            startActivity(intent);
        });
    }
}

// SecondActivity.java (Receiving data)
public class SecondActivity extends AppCompatActivity {
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_second);
        TextView textView = findViewById(R.id.textView);
        String message = getIntent().getStringExtra("message");
        textView.setText(message);
    }
}
    

Conclusion

Today we learned about activities and their lifecycle in Android app development,
transitions between activities via intents, and how to pass data.
These concepts are fundamental to Android app development and will serve as a starting point
for creating more complex apps.
In future lessons, we will cover more features and UI elements, so please stay tuned.

Java Android App Development Course, Activity Lifecycle

One of the most important concepts in Android app development is the Activity and its lifecycle. An Activity is a component that makes up the user interface (UI) and represents a screen that users interact with. In this course, we will explore the Activity lifecycle in Android app development using Java and explain the tasks that can be performed at each stage.

What is an Activity?

An Activity is a component that represents the user interface of an Android application and corresponds to a single screen within the app. Everything that the user interacts with in the app happens within an Activity. Activities include various UI elements to display information to the user and handle user interactions.

Activity Lifecycle

The Activity lifecycle refers to the flow of states and transitions from the creation to the destruction of an Activity. The Android system manages the Activity lifecycle, with the following key methods:

  • onCreate()
  • onStart()
  • onResume()
  • onPause()
  • onStop()
  • onDestroy()
  • onRestart()

1. onCreate()

The onCreate() method is called when the Activity is first created. It primarily performs UI setup and basic initialization tasks. In this method, the layout is set and initial variables are defined.

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

2. onStart()

The onStart() method is called just before the Activity becomes visible to the user. In this method, the UI can be initialized, signaling that the Activity is ready for user interaction.

@Override
protected void onStart() {
    super.onStart();
    // Handle just before the Activity is shown to the user
}

3. onResume()

The onResume() method is called when the Activity is about to become the foreground activity. Common tasks performed here include updating the UI or starting animations.

@Override
protected void onResume() {
    super.onResume();
    // Update UI or start animations
}

4. onPause()

The onPause() method is called when another Activity is starting or this Activity is being paused. In this method, data should be saved, or animations should be stopped. It indicates that the user is no longer actively using this Activity.

@Override
protected void onPause() {
    super.onPause();
    // Save data and stop animations
}

5. onStop()

The onStop() method is called when the Activity is no longer visible to the user. At this stage, resources should be released, and tasks that need to be handled when the Activity is not visible should be performed.

@Override
protected void onStop() {
    super.onStop();
    // Release resources and perform cleanup
}

6. onDestroy()

The onDestroy() method is called when the Activity is finishing. In this method, memory can be released and final cleanup tasks can be carried out. However, this method may not be called, so it is advisable to save important data in onPause() or onStop().

@Override
protected void onDestroy() {
    super.onDestroy();
    // Final cleanup tasks
}

7. onRestart()

The onRestart() method is called when the Activity is being restarted after stopping. This method is called after onStop(). Here, tasks to restore the previous state are performed.

@Override
protected void onRestart() {
    super.onRestart();
    // Tasks when restarting the Activity
}

Lifecycle Example

Now, let’s create an example that incorporates the Activity lifecycle explained earlier. In this example, we will log the Activity’s state through button clicks.

import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.widget.Button;
import androidx.appcompat.app.AppCompatActivity;

public class MainActivity extends AppCompatActivity {
    private static final String TAG = "MainActivity";

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

        Button button = findViewById(R.id.button);
        button.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Log.d(TAG, "Button clicked!");
            }
        });
    }

    @Override
    protected void onStart() {
        super.onStart();
        Log.d(TAG, "onStart called");
    }

    @Override
    protected void onResume() {
        super.onResume();
        Log.d(TAG, "onResume called");
    }

    @Override
    protected void onPause() {
        super.onPause();
        Log.d(TAG, "onPause called");
    }

    @Override
    protected void onStop() {
        super.onStop();
        Log.d(TAG, "onStop called");
    }

    @Override
    protected void onDestroy() {
        super.onDestroy();
        Log.d(TAG, "onDestroy called");
    }
}

Managing the Lifecycle

Managing the Activity lifecycle has a significant impact on the performance of the app and the user experience. Data that is necessary during the creation and destruction process should be saved in onPause() or onStop(), and the UI should be updated in onResume() when changes occur.

Saving State

When an Activity is restarted after being stopped, it may be necessary to save its state. You can use the onSaveInstanceState() method for this purpose. Below is an example of how to save state.

@Override
protected void onSaveInstanceState(Bundle outState) {
    super.onSaveInstanceState(outState);
    outState.putString("key", "value");
}

Saved state can be restored in onCreate() or onRestoreInstanceState().

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    
    if (savedInstanceState != null) {
        String value = savedInstanceState.getString("key");
    }
}

Conclusion

The Android Activity lifecycle is one of the fundamental components of an app, and understanding it and managing it effectively is important. Performing tasks correctly according to each stage of the lifecycle can provide a better user experience. I hope this course provides you with a basic understanding of the Activity lifecycle.

In conclusion, I have explained the Activity lifecycle in Android app development using Java. Deepen your understanding through practical exercises, and make good use of the lifecycle in various situations!

Java Android App Development Course, Activity ANR Issues and Coroutines

Providing an optimal user experience in Android development is extremely important. However, sometimes the ‘Application Not Responding’ (ANR) phenomenon can occur when asynchronous tasks are mishandled or when long tasks are executed on the main thread. ANR refers to situations when the app does not respond or crashes automatically while the user is interacting with the app. To avoid such situations and perform tasks more efficiently, Android Coroutine can be leveraged.

1. What is the ANR (and two other phenomena) problem?

ANR occurs when an application does not respond to user input for more than 5 seconds on Android. This problem typically arises when long tasks are executed on the main (UI) thread. To reduce these long tasks, many developers need to handle operations in an asynchronous manner.

1.1 Causes of ANR

Common causes of ANR include:

  • Network requests: When waiting on the main thread during communication with the server, especially if the network requests are long.
  • Database queries: When reading or writing a large amount of data, performing them on the main thread can cause ANR.
  • File I/O: When the task of reading or writing files takes too long.
  • Inefficient UI updates: When drawing long loops or complex layouts.

1.2 Impact of ANR issues

ANR issues have a significant impact on user experience. If the app freezes or responds slowly while the user is trying to use its features, this can lead to user attrition. Therefore, preventing and managing ANR issues is essential.

2. What are Android Coroutines?

Coroutines are lightweight threads that make asynchronous programming easier. While Kotlin coroutines are very popular, there are libraries that support coroutines in Java as well. If you can use Kotlin coroutines, you are likely already enjoying a lot of advantages. However, it is important to understand the concept of coroutines in various situations, including when using Java.

2.1 Advantages of Coroutines

  • Allows for easy writing of asynchronous tasks.
  • Reduces the number of threads and saves memory costs.
  • Provides a reliable structure that’s easy to manage errors.

3. Utilizing Coroutines to Solve ANR Problems

You can use kotlinx.coroutines to enable coroutines in Java. The following example illustrates how to address ANR issues.

3.1 Gradle Setup

First, add the following dependencies to your project’s build.gradle file:

    implementation "org.jetbrains.kotlinx:kotlinx-coroutines-core:"
    implementation "org.jetbrains.kotlinx:kotlinx-coroutines-android:"
    

3.2 Simple Coroutine Example

The following is an example of using coroutines to solve ANR issues. This example processes a network call asynchronously when the user clicks a button, ensuring that the main thread is not blocked.

    import kotlinx.coroutines.*;
    
    public class MainActivity extends AppCompatActivity {
        @Override
        protected void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);
            setContentView(R.layout.activity_main);
            Button button = findViewById(R.id.button);
    
            button.setOnClickListener(v -> {
                CoroutineScope(Dispatchers.Main).launch {
                    String result = fetchData();
                    // Update UI
                    TextView textView = findViewById(R.id.textView);
                    textView.setText(result);
                }
            });
        }
    
        private String fetchData() {
            // Example of network call
            String data;
            try {
                // Asynchronous network request
                data = performNetworkCall();
            } catch (Exception e) {
                data = "Error: " + e.getMessage();
            }
            return data;
        }
    
        private String performNetworkCall() throws InterruptedException {
            // Simulating an actual network call.
            Thread.sleep(2000);
            return "Data fetched successfully!";
        }
    }
    

3.3 Explanation of the Example

In this simple example, the fetchData() method is called when the button is clicked. This method performs the network request asynchronously to ensure that the main thread is not blocked. Users can interact with the interface, and UI elements are updated normally.

4. Going Further: Coroutine Handling and Listener Patterns

When using coroutines, you can utilize the listener pattern to update the UI when the network call is completed. The next example demonstrates how much simpler using coroutines is compared to callbacks.

    public class NetworkManager {
        public suspend String fetchUserData() throws Exception {
            // Asynchronous network request
            return withContext(Dispatchers.IO) {
                // Execute network task here
                Thread.sleep(2000);
                return "User data";
            };
        }
    }
    

5. Conclusion

Solving ANR issues in Android development is crucial for improving user experience. Coroutines are a powerful tool for handling asynchronous tasks easily. If you know how to manage data efficiently and prevent thread blocking while providing a responsive app to users, you can save time and increase efficiency.

Based on what you’ve learned in this lecture, try to avoid ANR issues in your own Android app projects and create a great user experience!

Java Android App Development Course, Displaying Notifications

One of the ways to convey important information or messages to users while developing an Android app is through notifications. Notifications are important UI elements that can capture the user’s attention and encourage interaction with the app. In this tutorial, we will take a closer look at how to create and display notifications in an Android app using Java.

1. Concept of Notification

In Android, a notification is a message that is displayed on the user’s device. Notifications generally consist of the following components:

  • Title: A brief display of the subject or main content of the notification.
  • Content: Contains the details intended to be conveyed in the notification.
  • Icon: Used for the visual representation of the notification.
  • Action: Defines the action to be performed when the user clicks on the notification.

2. Components of Android Notifications

The main components that must be used to display notifications are as follows:

  • NotificationManager: A system service that manages notifications.
  • NotificationChannel: Starting from Android O (API 26) and above, notification channels must be used to group notifications and provide settings to the user.

3. Steps to Show Notifications

3.1 Project Setup

Create a new project in Android Studio. At this time, select ‘Empty Activity’ and choose either Kotlin or Java as your programming language. Here, we will explain an example using Java.

3.2 Adding Required Permissions

Special permissions are not required to display notifications, but it is advisable to guide users to allow notifications in the app’s settings. Ensure that the following basic settings are included in AndroidManifest.xml:

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
        package="com.example.notificationexample">

        <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.3 Creating Notification Channel (API 26 and above)

You need to set up a NotificationChannel to create a channel through which notifications can be sent. Below is an example of creating a notification channel in the MainActivity.java file:

import android.app.NotificationChannel;
import android.app.NotificationManager;
import android.os.Build;

public class MainActivity extends AppCompatActivity {
    private static final String CHANNEL_ID = "notifyExample";

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

        createNotificationChannel();  // Call the method to create the channel
    }

    private void createNotificationChannel() {
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
            CharSequence name = "Example Channel";
            String description = "This is a channel for notification examples.";
            int importance = NotificationManager.IMPORTANCE_DEFAULT;
            NotificationChannel channel = new NotificationChannel(CHANNEL_ID, name, importance);
            channel.setDescription(description);
            NotificationManager notificationManager = getSystemService(NotificationManager.class);
            notificationManager.createNotificationChannel(channel);
        }
    }
}

3.4 Creating and Displaying Notifications

Now you are ready to create and display notifications. Here is an example of setting up a notification to be shown when a button is clicked.

import android.app.NotificationManager;
import android.app.PendingIntent;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;

import androidx.appcompat.app.AppCompatActivity;
import androidx.core.app.NotificationCompat;

public class MainActivity extends AppCompatActivity {
    private static final String CHANNEL_ID = "notifyExample";

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

        createNotificationChannel(); // Create notification channel

        Button button = findViewById(R.id.notify_button);
        button.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                sendNotification(); // Send notification
            }
        });
    }

    private void sendNotification() {
        Intent intent = new Intent(this, NotificationActivity.class);
        PendingIntent pendingIntent = PendingIntent.getActivity(this, 0, intent, PendingIntent.FLAG_UPDATE_CURRENT);

        NotificationCompat.Builder builder = new NotificationCompat.Builder(this, CHANNEL_ID)
                .setSmallIcon(R.drawable.ic_notification) // Icon to display
                .setContentTitle("New Notification") // Notification title
                .setContentText("Check the message here.") // Notification content
                .setPriority(NotificationCompat.PRIORITY_DEFAULT) // Set priority
                .setContentIntent(pendingIntent) // Set intent to execute on click
                .setAutoCancel(true); // Automatically delete on click

        NotificationManager notificationManager = (NotificationManager) getSystemService(NOTIFICATION_SERVICE);
        notificationManager.notify(1, builder.build()); // Create notification
    }
}

3.5 Handling Notification Clicks

To open a specific activity when the notification is clicked, you can handle it as follows. This involves creating and using a separate NotificationActivity class.

import android.os.Bundle;

import androidx.appcompat.app.AppCompatActivity;

public class NotificationActivity extends AppCompatActivity {
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_notification); // Reference appropriate layout file
    }
}

4. Various Options for Notifications

In addition to basic messages, various options can be utilized for notifications. Here are some commonly used options:

  • Sound: You can set a sound to play when the notification is displayed.
  • Vibration: You can make the device vibrate when the notification is triggered.
  • Suppress in Status Bar: You can control whether to display the notification in the status bar.

4.1 Adding Sound

Here is a code example for adding sound to a notification:

builder.setSound(Settings.System.DEFAULT_NOTIFICATION_URI); // Use default notification sound

4.2 Adding Vibration

Here’s how to add vibration to a notification:

VibrationUtils vibration = (VibrationUtils) getSystemService(Context.VIBRATOR_SERVICE);
    vibration.vibrate(1000); // Vibrate for 1 second

5. Grouping Notifications

You can also group multiple notifications for display. This can be set up using new channels and group IDs. Here is an example code:

NotificationCompat.Builder summaryBuilder = new NotificationCompat.Builder(this, CHANNEL_ID)
            .setContentTitle("Grouped Notification")
            .setContentText("There are multiple notifications.")
            .setSmallIcon(R.drawable.ic_launcher_foreground)
            .setGroup(GROUP_KEY_WORK_EMAIL)
            .setStyle(new NotificationCompat.InboxStyle()
                .addLine("First Notification")
                .addLine("Second Notification")
                .setSummaryText("+2 more"));

    notificationManager.notify(SUMMARY_ID, summaryBuilder.build()); // Create grouped notification

6. Cancelling Notifications

If you want to cancel a notification that has been created, you can use the cancel method of NotificationManager. Here’s an example of canceling a notification:

notificationManager.cancel(1); // Cancel a specific notification using its ID

7. Conclusion

In this tutorial, we thoroughly explored how to show notifications in Android. Notifications are a very useful feature for conveying important information to users. Implementing notification features in your project can enhance the user experience. Furthermore, consider ways to group notifications or adjust various options to provide more suitable notifications for users.

Today, you’ve learned how to create and display notifications in an Android app using Java. Remember to experiment with different notification options to enhance your app’s user experience!

Course on Java Android App Development, Features of Android App Development

1. Introduction

Android app development is a very important field in the current technology industry. Various apps are used on smartphones and tablets, making people’s daily lives more convenient. In this course, we will explore the characteristics of Android app development using Java, and conduct practical exercises through example code.

2. History of Android App Development

Android was developed by Android Inc. in 2003. After Google acquired Android Inc. in 2005, Android rapidly grew and became a widely used operating system across various platforms. It primarily operates on the Linux kernel, and apps are developed based on JAVA.

3. Setting Up the Android App Development Environment

To develop Android apps, you need to set up a development environment. The tools commonly used in this process are as follows:

  • Java Development Kit (JDK): A development tool for creating programs in Java.
  • Android Studio: Google’s official integrated development environment (IDE), which provides various tools and features necessary for creating Android apps.
  • Android SDK (Software Development Kit): Includes libraries and APIs needed for Android development.

Once the development environment is set up, run Android Studio and create a new project. After completing the necessary configurations during this process, we will create our first app.

4. Features of Android Apps Using Java

Java is used as the primary programming language for Android, and many developers prefer it due to its stability and portability. Features of Android apps using Java include:

4.1. Object-Oriented Programming

Java is an object-oriented programming (OOP) language that structures code using classes and objects. This increases the reusability of the code and makes maintenance easier.

4.2. Portability

Applications developed in Java run on the JVM (Java Virtual Machine), so they possess portability that allows them to be used on various platforms.

4.3. Rich Libraries and APIs

Java provides various libraries and APIs that help developers implement functionalities more easily. The Android SDK includes UI components, networking, database functionalities, and more.

4.4. Concurrency

Android apps support asynchronous tasks. By using Java’s thread class, UI and backend tasks can be performed simultaneously.

5. Understanding the Structure of Android Apps

Android apps are generally composed of Activity, Service, Broadcast Receiver, and Content Provider.

5.1. Activity

An Activity creates the user interface and represents one screen of the app. Activities are important components for interacting with the user.

5.2. Service

A Service is a component that runs continuously in the background, used for tasks that require long execution time.

5.3. Broadcast Receiver

A Broadcast Receiver is a component that detects events occurring from the system or other apps.

5.4. Content Provider

A Content Provider provides a mechanism for sharing data between apps.

6. Basic Example: Creating Your First Android App

Now let’s create a simple Android app using Java. This app will have the functionality to take input from users and output it. Below are the steps.

6.1. Creating a Project in Android Studio

  1. Run Android Studio and create a new project.
  2. Select “Empty Activity” as the project template and enter the project name.
  3. Next, set the base package name and save path.
  4. Finally, click the Finish button to complete the project creation.

6.2. Creating the UI Layout

Now we will create the user interface through the XML file. Modify the res/layout/activity_main.xml file as follows:

                
                <?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">

                    <EditText
                        android:id="@+id/editText"
                        android:layout_width="match_parent"
                        android:layout_height="wrap_content"
                        android:hint="Enter your input" />

                    <Button
                        android:id="@+id/button"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:layout_below="@+id/editText"
                        android:text="Submit" />

                    <TextView
                        android:id="@+id/textView"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:layout_below="@+id/button"
                        android:text="Result" />

                </RelativeLayout>
                
            

6.3. Writing Code for MainActivity.java

Now, let’s write the code in the MainActivity.java file to handle user input and display the result.

                
                package com.example.myfirstapp;

                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 {

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

                        EditText editText = findViewById(R.id.editText);
                        Button button = findViewById(R.id.button);
                        TextView textView = findViewById(R.id.textView);
                        
                        button.setOnClickListener(new View.OnClickListener() {
                            @Override
                            public void onClick(View v) {
                                String input = editText.getText().toString();
                                textView.setText("Input value: " + input);
                            }
                        });
                    }
                }
                
            

6.4. Running the App

After writing the code, run the app in Android Studio. You can test the app by connecting an emulator or a real Android device.

7. Publishing the Android App

Once app development is complete, it can be distributed on the Google Play Store. You just need to create an App Bundle or APK file for upload. During this process, you need to set the app’s icon, description, screenshots, etc.

8. Conclusion

Developing Android apps using Java is an attractive and challenging experience. I hope this course has helped you understand the basic development process and the characteristics of Android app development through practice. Based on this knowledge, I encourage you to move on to the next step and develop more diverse apps.

This article provides basic information on Java Android app development. If you have any questions at any stage, please feel free to ask in the comments. Thank you.