admin
-
Android – Building a Dynamic Broadcast Receiver
1 Create the Receiver Class First, create MyReceiver.java. This class extends BroadcastReceiver. The onReceive() method is triggered instantly by the system whenever the specified event (in this case, toggling Airplane Mode) occurs. Copy package com.example.android_broadcastreceivers; import android.content.BroadcastReceiver; import android.content.Context; import android.content.Intent; import android.widget.Toast; public class MyReceiver extends BroadcastReceiver { @Override public void onReceive(Context context, Intent intent) { // Check if the received action is the Airplane Mode change if (Intent.ACTION_AIRPLANE_MODE_CHANGED.equals(intent.getAction())) { // Get the current state (true = on, false…
-
Building an Android Started Service
1 Create the Service Class First, create MyService.java. This class handles the background work. Because a service runs on the main UI thread by default, heavy operations should be offloaded to a separate Thread here. Copy package com.example.android_service; import android.app.Service; import android.content.Intent; import android.os.IBinder; import android.util.Log; import android.widget.Toast; public class MyService extends Service { private static final String TAG = “MyService”; @Override public void onCreate() { super.onCreate(); Log.d(TAG, “Service Created”); } @Override public int onStartCommand(Intent intent, int flags, int startId)…
-
Android Tutorial: Master-Detail UI with RecyclerView and Fragments
In this tutorial, we will build a modern, list-based Android application. We will use a Single Activity Architecture, meaning our main screen will be hosted inside a Fragment. We will implement both a horizontal and a vertical RecyclerView on the home screen, and make them clickable to open a separate Detail Screen. App Preview: What We Are Building Interact with the phone below! You can scroll the top section horizontally, and the bottom section vertically, demonstrating the standard Android RecyclerView…
-
CRUD Android App with RecyclerView, Room and Fragment
Building a CRUD App with RecyclerView, Room, and Fragment In this tutorial, we will build a complete CRUD (Create, Read, Update, Delete) application in Android. We will use a Fragment to manage our User Interface, RecyclerView to display a list of names, and Room Database to store those names locally. Step 1: Add Dependencies (build.gradle) First, add the Room dependencies to your module-level build.gradle file inside the dependencies block. Copy dependencies { def room_version = “2.6.1” implementation “androidx.room:room-runtime:$room_version” annotationProcessor “androidx.room:room-compiler:$room_version”…
-
Android Tutorial on RecyclerView, Room and Fragment
Building a Task List App: RecyclerView, Room, and Fragment This is a great combination of core Android topics. To demonstrate RecyclerView, Room, and Fragment working together, we will build a simple Task List App. The app will use a Fragment to display a user interface, Room to save tasks to a local SQLite database, and a RecyclerView to display that list of tasks. Step 1: Add Dependencies (build.gradle) First, you need to add the Room dependencies. Open your app-level build.gradle…
-
SharedPreferences – Android (Java)
SharedPreferences The “Save Game” of Android Development, Explored & Visualized Storing small bits of data shouldn’t require a full database. SharedPreferences allows you to persist key-value pairs easily. Whether it’s a user’s high score or a “Dark Mode” toggle, this API has been the backbone of Android persistence for years. Try the Simulator Click the buttons to see the UI update instantly, then watch apply() write the data to the Disk Storage in the background. Android UI 0 Current Counter…
-
Tutorial: Your First Android App (Hello World)
This guide covers the essential steps to create a functional “Hello World” application in Android Studio. 1. Project Setup 2. Designing the Layout (XML) Android uses XML for UI design. Navigate to res -> layout -> activity_main.xml. This file defines how your app looks. 3. Writing the Logic (Java) Now, navigate to java -> com.example.myfirstapp -> MainActivity.java. This is where you tell the app what to do when the user interacts with the UI. 4. Running the App