Found 2041 Articles for Mobile Development

How do I declare global variables on Android using Kotlin?

Azhar
Updated on 28-Nov-2020 11:06:04

4K+ Views

This example demonstrates how to declare global variables on Android using Kotlin.Step 1 − Create a new project in Android Studio, go to File ⇒ New Project and fill all required details to create a new project.Step 2 − Add the following code to res/layout/activity_main.xml.         Step 3 − Add the following code to src/MainActivity.ktimport android.os.Bundle import android.widget.TextView import androidx.appcompat.app.AppCompatActivity class MainActivity : AppCompatActivity() {    lateinit var textView: TextView    override fun onCreate(savedInstanceState: Bundle?) {       super.onCreate(savedInstanceState)       setContentView(R.layout.activity_main)       title = "KotlinApp"       textView = findViewById(R.id.text) ... Read More

How to get screen dimensions in pixels on Android App using Kotlin?

Azhar
Updated on 28-Nov-2020 11:02:01

1K+ Views

This example demonstrates how to get screen dimensions in pixels on the Android App using Kotlin.Step 1 − Create a new project in Android Studio, go to File ⇒ New Project and fill all required details to create a new project.Step 2 − Add the following code to res/layout/activity_main.xml.             Step 3 − Add the following code to src/MainActivity.ktimport android.os.Bundle import android.util.DisplayMetrics import android.view.WindowManager import android.widget.TextView import androidx.appcompat.app.AppCompatActivity class MainActivity : AppCompatActivity() {    lateinit var tvHeight: TextView    lateinit var tvWidth: TextView    override fun onCreate(savedInstanceState: Bundle?) {       super.onCreate(savedInstanceState)   ... Read More

How ListView's recycling mechanism works on Android using Kotlin?

Azhar
Updated on 28-Nov-2020 10:47:59

163 Views

This example demonstrates how to show the working of ListView's recycling mechanism on Android Kotlin.Step 1 − Create a new project in Android Studio, go to File ⇒   New Project and fill all required details to create a new project.Step 2 − Add the following code to res/layout/activity_main.xml.     Step 3 − Add the following code to src/MainActivity.ktimport android.os.Bundle import android.view.* import android.widget.Toast import androidx.appcompat.app.AppCompatActivity import androidx.recyclerview.widget.LinearLayoutManager import androidx.recyclerview.widget.RecyclerView class MainActivity : AppCompatActivity() {    private lateinit var cities:ArrayList    override fun onCreate(savedInstanceState: Bundle?) {       super.onCreate(savedInstanceState)       setContentView(R.layout.activity_main)       title ... Read More

How to write a custom adapter for my list view on Android using Kotlin?

Azhar
Updated on 28-Nov-2020 08:37:42

5K+ Views

This example demonstrates how to write a custom adapter for my list view on Android using Kotlin.Step 1 − Create a new project in Android Studio, go to File ⇒ New Project and fill all required details to create a new project.Step 2 − Add the following code to res/layout/activity_main.xml.     Step 3 − Add the following code to src/MainActivity.ktimport android.content.Context import android.os.Bundle import android.view.LayoutInflater import android.view.View import android.view.ViewGroup import android.widget.BaseAdapter import android.widget.ListView import android.widget.TextView import androidx.appcompat.app.AppCompatActivity class MainActivity : AppCompatActivity() {    lateinit var listView: ListView    var arrayList: ArrayList = ArrayList()    var adapter: MyAdapter? = ... Read More

How to show current progress while downloading a file on Android App using Kotlin?

Azhar
Updated on 28-Nov-2020 08:27:57

403 Views

This example demonstrates how to show current progress while downloading a file on Android App using Kotlin.Step 1 − Create a new project in Android Studio, go to File ⇒ New Project and fill all required details to create a new project.Step 2 − Add the following code to res/layout/activity_main.xml.         Step 3 − Add the following code to src/MainActivity.ktimport android.os.Bundle import android.view.View import android.webkit.WebView import android.widget.ProgressBar import androidx.appcompat.app.AppCompatActivity class MainActivity : AppCompatActivity() {    lateinit var webView: WebView    lateinit var progressBar: ProgressBar    override fun onCreate(savedInstanceState: Bundle?) {       super.onCreate(savedInstanceState)     ... Read More

How to crop a circular area from bitmap in Android using Kotlin?

Azhar
Updated on 28-Nov-2020 08:21:49

597 Views

This example demonstrates how to crop a circular area from bitmap in Android using Kotlin.Step 1 − Create a new project in Android Studio, go to File ⇒ New Project, and fill all required details to create a new project.Step 2 − Add the following code to res/layout/activity_main.xml.         Step 3 − Add the following code to src/MainActivity.ktimport android.graphics.* import android.os.Bundle import android.widget.Button import android.widget.ImageView import androidx.appcompat.app.AppCompatActivity import kotlin.math.min class MainActivity : AppCompatActivity() {    lateinit var button: Button    lateinit var imageView: ImageView    lateinit var bitmap: Bitmap    override fun onCreate(savedInstanceState: Bundle?) ... Read More

The Bluetooth Frame Structure

Moumita
Updated on 11-Sep-2020 10:49:51

4K+ Views

The Bluetooth network technology connects mobile devices wirelessly using short-wavelength, ultra-high frequency (UHF) radio waves over a short range to form a personal area network (PAN). Data is transferred between the Bluetooth devices as data frames. Two basic frame formats are defined, for transmitting data at basic data rate and for transmitting data at enhanced data rate.Bluetooth Frame Format with Basic Data RateA Bluetooth frame with basic rate has three parts, access code, header and data as shown in the following diagram−The various fields are−Access Code− A 72-bit field containing synchronization bits to identify the master.Header− A 54-bit field containing ... Read More

Asynchronous Connection-Less (ACL) Link

Moumita
Updated on 11-Sep-2020 10:48:24

1K+ Views

Bluetooth link layers define two types of data links, Asynchronous Connection-Less (ACL) Link, being one of them. It is the type of link used for transmission of general data packets using Bluetooth connection. ACL is a point – to – multipoint link used for irregular traffic between a master device and one or more slave devices.Features of Bluetooth ACL linksACL is a packet oriented link, i.e. the link establishes a packet – switched network.ACL is used for transmission of data traffic which are delivered at irregular intervals, where maintaining data integrity is more important than the time latency.Both symmetric and ... Read More

Synchronous Connection-Oriented (SCO) Link

Moumita
Updated on 11-Sep-2020 10:43:39

2K+ Views

Bluetooth link layers define two types of data links, Synchronous Connection Oriented (SCO) link, being one of them. SCO is a symmetric, point-to-point link between the master device and the slave device connected via Bluetooth.Features of Bluetooth SCO linksIn SCO, a dedicated, point-to-point link is established between the master device and the slave device before communication starts.SCO is a symmetric link, i.e. fixed slots are allocated for each direction.Since fixed slots are reserved, SCO provides a circuit switched connection.SCO radio links are used for time critical data transfer, particularly for voice data.Both the master and the slave device transmit encoded ... Read More

Difference between ACL and SCO Link in Bluetooth

Moumita
Updated on 11-Sep-2020 10:42:17

4K+ Views

Two types of data links are defined by Bluetooth link layers−Synchronous Connection Oriented (SCO) LinkAsynchronous Connection-Less (ACL) LinkSCO is a symmetric, point-to-point link between the master device and the slave device connected via Bluetooth.ACL is a point – to – multipoint link for transmitting general data packets using Bluetooth connection. ACL is used for irregular traffic between a master device and one or more slave devices.Differences between SCO and ACLSCOACL1SCO provides a circuit switched connection, where a dedicated, point-to-point link is established between the master device and the slave device before communication starts.ACL is a packet oriented link, i.e. the ... Read More

Advertisements