Kotlin Articles

Page 17 of 21

Sending an Intent to browser to open specific URL using Kotlin.

Azhar
Azhar
Updated on 26-May-2020 3K+ Views

This example demonstrates how to Send an Intent to browser to open specific URL 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.Example         Step 3 − Add the following code to src/MainActivity.ktExampleimport android.content.Intent import android.net.Uri import androidx.appcompat.app.AppCompatActivity import android.os.Bundle import android.view.View class MainActivity : AppCompatActivity() {    override fun onCreate(savedInstanceState: Bundle?) {       super.onCreate(savedInstanceState)       setContentView(R.layout.activity_main)       title = "KotlinApp"    }   ...

Read More

How to get Value of a Edit Text field in Android using Kotlin?

Azhar
Azhar
Updated on 26-May-2020 7K+ Views

This example demonstrates how to  get Value of a Edit Text field 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.widget.Button import android.widget.EditText import android.widget.TextView import androidx.appcompat.app.AppCompatActivity class MainActivity : AppCompatActivity() {    lateinit var button: Button    lateinit var editText: EditText    lateinit var string: String    lateinit var textView: ...

Read More

How to call an activity method from a fragment in Android App using Kotlin.

Azhar
Azhar
Updated on 26-May-2020 5K+ Views

This example demonstrates how to call an activity method from a fragment 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.os.Bundle import android.widget.Toast import androidx.appcompat.app.AppCompatActivity class MainActivity : AppCompatActivity() {    override fun onCreate(savedInstanceState: Bundle?) {       super.onCreate(savedInstanceState)       setContentView(R.layout.activity_main)       title = "KotlinApp"       val fragmentManager ...

Read More

How to check the amount of RAM to be used by an Android App using Kotlin?

Azhar
Azhar
Updated on 23-May-2020 735 Views

This example demonstrates how to create a smooth image rotation 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.Example         Step 3 − Add the following code to src/MainActivity.ktExampleimport android.app.ActivityManager import android.content.Context import android.os.Bundle import android.widget.TextView import androidx.appcompat.app.AppCompatActivity class MainActivity : AppCompatActivity() {    private lateinit var textView: TextView    override fun onCreate(savedInstanceState: Bundle?) {       super.onCreate(savedInstanceState)       setContentView(R.layout.activity_main)       title = "KotlinApp" ...

Read More

How to create a smooth image rotation in Android using Kotlin?

Azhar
Azhar
Updated on 23-May-2020 448 Views

This example demonstrates how to create a smooth image rotation 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.Example         Step 3 − Add the following code to src/MainActivity.ktExampleimport android.os.Bundle import android.view.animation.AnimationUtils import android.widget.Button import android.widget.ImageView import androidx.appcompat.app.AppCompatActivity class MainActivity : AppCompatActivity() {    lateinit var imageView: ImageView    lateinit var button: Button    override fun onCreate(savedInstanceState: Bundle?) {       super.onCreate(savedInstanceState)       setContentView(R.layout.activity_main)       ...

Read More

How to convert a Bitmap to Drawable in Kotlin?

Azhar
Azhar
Updated on 23-May-2020 2K+ Views

This example demonstrates how to convert a Bitmap to Drawable in 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.Example         Step 3 − Add the following code to src/MainActivity.ktExampleimport android.graphics.Bitmap import android.graphics.drawable.BitmapDrawable import android.graphics.drawable.Drawable import android.os.Bundle import android.widget.Button import android.widget.ImageView import androidx.appcompat.app.AppCompatActivity class MainActivity : AppCompatActivity() {    lateinit var imageView: ImageView    lateinit var button: Button    lateinit var bitmap: Bitmap    lateinit var drawable: Drawable    override fun onCreate(savedInstanceState: ...

Read More

How to add Google Search Functionality in an Android App using Kotlin?

Azhar
Azhar
Updated on 23-May-2020 494 Views

This example demonstrates how to add Google Search Functionality 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.Example             Step 3 − Add the following code to src/MainActivity.ktExampleimport android.app.SearchManager import android.content.Intent import android.os.Bundle import android.widget.Button import android.widget.EditText import androidx.appcompat.app.AppCompatActivity class MainActivity : AppCompatActivity() {    lateinit var editText: EditText    lateinit var btnSearch: Button    override fun onCreate(savedInstanceState: Bundle?) {       super.onCreate(savedInstanceState)   ...

Read More

How to get the differences between two dates in Android using Kotlin?

Azhar
Azhar
Updated on 23-May-2020 2K+ Views

This example demonstrates how to create a simple alert dialog with Ok and cancel buttons 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.Example         Step 3 − Add the following code to src/MainActivity.ktExampleimport android.os.Bundle import android.widget.TextView import androidx.appcompat.app.AppCompatActivity import java.text.SimpleDateFormat import java.util.* import kotlin.math.abs class MainActivity : AppCompatActivity() {    lateinit var textView: TextView    override fun onCreate(savedInstanceState: Bundle?) {       super.onCreate(savedInstanceState)       setContentView(R.layout.activity_main)   ...

Read More

How to create a simple alert dialog with Ok and cancel buttons using Kotlin?

Azhar
Azhar
Updated on 23-May-2020 2K+ Views

This example demonstrates how to create a simple alert dialog with Ok and cancel buttons 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.Example         Step 3 − Add the following code to src/MainActivity.ktExampleimport android.os.Bundle import android.widget.TextView import android.widget.Toast import androidx.appcompat.app.AlertDialog import androidx.appcompat.app.AppCompatActivity class MainActivity : AppCompatActivity() {    private lateinit var textView: TextView    override fun onCreate(savedInstanceState: Bundle?) {       super.onCreate(savedInstanceState)       setContentView(R.layout.activity_main)       ...

Read More

How to request Location Permission at runtime on Kotlin?

Azhar
Azhar
Updated on 23-May-2020 8K+ Views

This example demonstrates how to request Location Permission at runtime on 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.Example         Step 3 − Add the following code to src/MainActivity.ktExampleimport android.content.pm.PackageManager import androidx.appcompat.app.AppCompatActivity import android.os.Bundle import android.widget.Toast import androidx.core.app.ActivityCompat import androidx.core.content.ContextCompat class MainActivity : AppCompatActivity() {    override fun onCreate(savedInstanceState: Bundle?) {       super.onCreate(savedInstanceState)       setContentView(R.layout.activity_main)       title = "KotlinApp"       if (ContextCompat.checkSelfPermission(this@MainActivity,   ...

Read More
Showing 161–170 of 202 articles
« Prev 1 15 16 17 18 19 21 Next »
Advertisements