Found 2041 Articles for Mobile Development

How to check if Location Services are enabled in Android App using Kotlin?

Azhar
Updated on 30-Nov-2020 07:08:00

1K+ Views

This example demonstrates how to check if Location Services are enabled in 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.content.Context import android.location.LocationManager import android.os.Bundle import android.widget.Button import android.widget.TextView import androidx.appcompat.app.AppCompatActivity class MainActivity : AppCompatActivity() {    var gpsStatus: Boolean = false    private lateinit var textView: TextView    override fun onCreate(savedInstanceState: Bundle?) {   ... Read More

How to create circular ProgressBar in Android using Kotlin?

Azhar
Updated on 30-Nov-2020 07:02:52

2K+ Views

This example demonstrates how to create a circular ProgressBar 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 − Create a drawable resource file (circularprogressbar.xml) and add the following code    android:layout_width="wrap_content"    android:layout_height="wrap_content">                                                   ... Read More

How to detect click on HTML button through javascript in Android WebView using Kotlin?

Azhar
Updated on 30-Nov-2020 06:56:01

1K+ Views

This example demonstrates how to detect click on HTML buttons through javascript in Android WebView using Kotlin.This example demonstrates how to detect click on HTML buttons through javascript in Android WebView 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 − Create an asset folder and create a file.htm and add the following code − First name: Last name:    function getValues() { ... Read More

How to make a phone call using intent in Android using Kotlin?

Azhar
Updated on 30-Nov-2020 06:31:34

3K+ Views

This example demonstrates how to make a phone call using intent in Android using KotlinStep 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.Intent import android.net.Uri import android.os.Bundle import android.view.View import androidx.appcompat.app.AppCompatActivity class MainActivity : AppCompatActivity() {    override fun onCreate(savedInstanceState: Bundle?) {       super.onCreate(savedInstanceState)       setContentView(R.layout.activity_main)       title = "KotlinApp"    }    fun ... Read More

How to turn Android device screen on and off programmatically using Kotlin?

Azhar
Updated on 30-Nov-2020 05:28:49

1K+ Views

This example demonstrates how to turn an Android device screen on and off programmatically 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.app.admin.DevicePolicyManager import android.content.ComponentName import android.content.Context import android.content.Intent import android.os.Bundle import android.view.View import android.widget.Button import android.widget.Toast import androidx.annotation.Nullable import androidx.appcompat.app.AppCompatActivity class MainActivity : AppCompatActivity() {    private val enableResult = 1   ... Read More

How to resize Image in Android App using Kotlin?

Azhar
Updated on 30-Nov-2020 05:23:02

3K+ Views

This example demonstrates how to resize Image in an 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.app.Activity 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.ImageView import androidx.appcompat.app.AppCompatActivity import java.io.IOException class MainActivity : AppCompatActivity() {    lateinit var imageView: ImageView    private val pickImage = ... Read More

How to create pagination text in Android using Kotlin?

Azhar
Updated on 18-Aug-2020 12:35:49

251 Views

This example demonstrates how to create pagination text 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.Color import android.graphics.Typeface import android.os.Bundle import android.text.Html import android.text.Spannable import android.text.SpannableString import android.text.TextUtils import android.text.style.ForegroundColorSpan import android.text.style.RelativeSizeSpan import android.text.style.StyleSpan import android.view.ViewTreeObserver import android.widget.Button import android.widget.TextView import androidx.appcompat.app.AppCompatActivity class MainActivity : AppCompatActivity() {    lateinit var ... Read More

How to implement a long click listener on an Android listview using Kotlin?

Azhar
Updated on 18-Aug-2020 12:30:38

793 Views

This example demonstrates how to implement a long click listener on an Android listview 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 projectStep 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.AdapterView.OnItemLongClickListener import android.widget.ArrayAdapter import android.widget.ListView import android.widget.Toast import androidx.appcompat.app.AppCompatActivity class MainActivity : AppCompatActivity() {    var mobileArray = arrayOf("Android", "IPhone", "WindowsMobile", "Blackberry", "WebOS", "Ubuntu", "Windows7", "Max OS X")    override fun onCreate(savedInstanceState: Bundle?) {       ... Read More

How to make a GridLayout fit screen size in Android using Kotlin?

Azhar
Updated on 18-Aug-2020 12:28:43

477 Views

This example demonstrates how to make a GridLayout fit screen size in Android using Kotlin.Step 1 − Create a new project in a new projectStep 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.Gravity import android.widget.GridLayout import android.widget.ImageView import android.widget.TableLayout import androidx.appcompat.app.AppCompatActivity class MainActivity : AppCompatActivity() {    override fun onCreate(savedInstanceState: Bundle?) {       ... Read More

How do we set the input type for an Android EditText programmatically using Kotlin?

Azhar
Updated on 18-Aug-2020 12:25:31

1K+ Views

This example demonstrates how to set the input type for an Android EditText programmatically 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 androidx.appcompat.app.AppCompatActivity import android.os.Bundle import android.text.InputType import android.view.View import android.widget.EditText class MainActivity : AppCompatActivity() {    private lateinit var editText: EditText    override fun onCreate(savedInstanceState: Bundle?) {       super.onCreate(savedInstanceState)       setContentView(R.layout.activity_main)   ... Read More

Advertisements