Found 1952 Articles for Apps/Applications

How do I get the resource id of an image if I know its name in Android using Kotlin?

Azhar
Updated on 30-Nov-2020 11:43:36

1K+ Views

This example demonstrates how to get the resource id of an image if I know its name 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 androidx.appcompat.app.AppCompatActivity import android.os.Bundle import android.widget.TextView class MainActivity : AppCompatActivity() {    override fun onCreate(savedInstanceState: Bundle?) {       super.onCreate(savedInstanceState)       setContentView(R.layout.activity_main)       title = "KotlinApp"     ... Read More

How to make an Android device vibrate programmatically using Kotlin?

Azhar
Updated on 30-Nov-2020 11:40:34

2K+ Views

This example demonstrates how to make an Android device vibrate 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.content.Context import android.os.Build import android.os.Bundle import android.os.VibrationEffect import android.os.Vibrator import androidx.appcompat.app.AppCompatActivity @Suppress("DEPRECATION") class MainActivity : AppCompatActivity() {    override fun onCreate(savedInstanceState: Bundle?) {       super.onCreate(savedInstanceState)       setContentView(R.layout.activity_main)       title = "KotlinApp"       ... Read More

How to define a MIN and MAX value for EditText in Android using Kotlin?

Azhar
Updated on 30-Nov-2020 07:25:16

857 Views

This example demonstrates how to define a MIN and MAX value for EditText 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.os.Bundle import android.text.InputFilter import android.text.Spanned import android.widget.EditText import android.widget.TextView import androidx.appcompat.app.AppCompatActivity import kotlinx.android.synthetic.main.activity_main.* class MainActivity : AppCompatActivity() {    lateinit var textView: TextView    override fun onCreate(savedInstanceState: Bundle?) {       super.onCreate(savedInstanceState)   ... Read More

How can I validate EditText input in Android using Kotlin?

Azhar
Updated on 30-Nov-2020 07:14:29

1K+ Views

This example demonstrates how to validate EditText input 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.os.Bundle import android.text.InputFilter import android.text.Spanned import android.widget.EditText import android.widget.TextView import androidx.appcompat.app.AppCompatActivity import kotlinx.android.synthetic.main.activity_main.* import java.util.regex.Matcher import java.util.regex.Pattern class MainActivity : AppCompatActivity() {    private lateinit var textView: TextView    override fun onCreate(savedInstanceState: Bundle?) {       super.onCreate(savedInstanceState)   ... Read More

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

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

2K+ 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

4K+ 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

2K+ 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

4K+ 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

Advertisements