Posts

Showing posts from July, 2018

Spinner - Android Studio - Java

Image
How to use the Spinner in Android Studio with Java In this tutorial, you’ll learn how to use a Spinner in Android Studio using Java . A Spinner in Android works like a drop-down menu that displays a list of values, allowing the user to select one option at a time . The Android Spinner is part of the AdapterView family, which means it requires an Adapter to bind data to the UI. In this example, we’ll use an adapter to populate the Spinner with items and handle user selection events. >> Check For Java >> Check For Kotlin >> Check For Compose Code: activity_main.xml <?xml version="1.0" encoding="utf-8"?> <LinearLayout 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" android:o...

Bluetooth Example

Image
Using BluetoothAdapter class we will do the following operations Check if Bluetooth is available or not. Turn On/Off Bluetooth. Make Bluetooth Discoverable. Display Paired/Bounded devices. Note: The getBoundedDevices() method of BluetoothAdapter class provides a set containing list of all paired or bounded bluetooth devices. Permissions Required: BLUETOOTH, BLUETOOTH_ADMIN Step 1:  Create a new project   OR   Open your project Step 2:  Add 2 Images to show Bluetooth status icons Step 3:  Add  BLUETOOTH, BLUETOOTH_ADMIN  permission in AndroidMenifest.xml Step 4: Code AndroidManifest.xml <?xml version="1.0" encoding="utf-8"?> <manifest xmlns:android= "http://schemas.android.com/apk/res/android" package= "com.blogspot.atifsoftwares.bluetoothexample" > <uses-permission android:name= "android.permission.BLUETOOTH" /> <uses-permission android:na...

Check Network Status - Android Studio - Java

Image
How to check Network Connection Status In this tutorial, you will learn how to detect the type of internet connection in an Android app using Java. We will check whether the device has no internet connection , is connected through Wi-Fi , or is using Mobile Data . This is a common feature in modern Android applications to improve user experience and handle offline scenarios smoothly. By the end of this guide, you’ll understand how to access the Android network services, detect connection status programmatically, and display meaningful messages to users based on their connectivity state. >> Check For Java >> Check For Kotlin >> Check For Compose Code: AndroidManifest.xml <?xml version="1.0" encoding="utf-8"?> <manifest xmlns:android= "http://schemas.android.com/apk/res/android" xmlns:tools= "http://schemas.android.com/tools" > <uses-permission android:name= "android.permission.ACCESS_NETWORK_ST...