Found 417 Articles for Kotlin

How to programmatically turn off and turn on WiFi in Kotlin?

Azhar
Updated on 21-Apr-2020 10:00:43

963 Views

This example demonstrates programmatically turning off and turning on WiFi 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.             Step 3 − Add the following code to MainActivity.ktimport android.net.wifi.WifiManager import androidx.appcompat.app.AppCompatActivity import android.os.Bundle import android.view.View import android.widget.Toast class MainActivity : AppCompatActivity() {    lateinit var wifiManager: WifiManager    override fun onCreate(savedInstanceState: Bundle?) {       super.onCreate(savedInstanceState)       setContentView(R.layout.activity_main)       title = "KotlinApp" ... Read More

How to add Google Search Functionality in Kotlin?

Azhar
Updated on 21-Apr-2020 09:57:39

514 Views

This example demonstrates how to add Google Search Functionality 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.                 Step 3 − Add the following code to MainActivity.ktimport 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 integrate Facebook using Kotlin?

Azhar
Updated on 21-Apr-2020 09:55:49

2K+ Views

This example demonstrates how to integrate Facebook 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 − In your project, open your_app | Gradle Scripts | build.gradle (Module: app) and add the following compile statement to the dependencies{} section to compile the latest version of the SDK −implementation 'com.facebook.android:facebook-login:5.15.3'Step 3 − Add your package name and default activity class name as shown below, click save and continue.Step 4 − Create a Key hash. Based on your operating system you have to copy ... Read More

How to play videos in Android TextureView using Kotlin?

Azhar
Updated on 21-Apr-2020 09:44:38

393 Views

This example demonstrates how to play videos in Android TextureView 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 copy-paste the video into the asset folder.Step 4 − Add the following code to MainActivity.ktimport android.content.res.AssetFileDescriptor import android.graphics.SurfaceTexture import android.media.MediaPlayer import android.media.MediaPlayer.OnVideoSizeChangedListener import android.os.Build import android.os.Bundle import android.view.Surface import android.view.TextureView import android.view.TextureView.SurfaceTextureListener import androidx.appcompat.app.AppCompatActivity import java.io.IOException class MainActivity : AppCompatActivity(), SurfaceTextureListener, OnVideoSizeChangedListener {    private ... Read More

How to use the TextWatcher class in kotlin?

Azhar
Updated on 21-Apr-2020 09:42:30

4K+ Views

This example demonstrates how to use the TextWatcher class 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.                 Step 3 − Add the following code to MainActivity.ktimport android.os.Bundle import android.text.Editable import android.text.TextWatcher import android.widget.EditText import android.widget.TextView import android.widget.Toast import androidx.appcompat.app.AppCompatActivity class MainActivity : AppCompatActivity() {    lateinit var input: EditText    lateinit var output: TextView    override fun onCreate(savedInstanceState: Bundle?) {       super.onCreate(savedInstanceState)   ... Read More

How can I send emails using gmail from my Android application using Kotlin?

Azhar
Updated on 21-Jul-2020 09:06:22

2K+ Views

This example demonstrates how to send emails using gmail from my Android application 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 MainActivity.ktimport 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 editTextMail: EditText    lateinit var editTextSubject: EditText    lateinit var editTextMessage: ... Read More

How to set the part of the Android text view as clickable in Kotlin?

Azhar
Updated on 21-Apr-2020 09:34:08

1K+ Views

This example demonstrates how to set the part of the Android text view as clickable 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.         Step 3 − Add the following code to MainActivity.ktimport android.os.Bundle import android.text.SpannableString import android.text.Spanned import android.text.method.LinkMovementMethod import android.text.style.ClickableSpan import android.view.View import android.widget.TextView import android.widget.Toast import androidx.appcompat.app.AppCompatActivity class MainActivity : AppCompatActivity() {    lateinit var textView: TextView    override fun onCreate(savedInstanceState: Bundle?) {       super.onCreate(savedInstanceState) ... Read More

How to quit an android application programmatically using Kotlin?

Azhar
Updated on 21-Apr-2020 09:30:40

2K+ Views

This example demonstrates how to quit an android application 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 MainActivity.ktimport androidx.appcompat.app.AppCompatActivity import android.os.Bundle import android.view.View import kotlin.system.exitProcess class MainActivity : AppCompatActivity() {    override fun onCreate(savedInstanceState: Bundle?) {       super.onCreate(savedInstanceState)       setContentView(R.layout.activity_main)       title = "KotlinApp"    }    fun quitApp(view: View) {   ... Read More

How to create Text to Speech in an Android App using Kotlin?

Azhar
Updated on 21-Apr-2020 09:27:56

696 Views

This example demonstrates how to create Text to Speech 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 MainActivity.ktimport android.app.Activity import android.content.Intent import android.os.Bundle import android.speech.RecognizerIntent import android.widget.ImageView import android.widget.TextView import android.widget.Toast import androidx.appcompat.app.AppCompatActivity import java.util.* import kotlin.collections.ArrayList class MainActivity : AppCompatActivity() {    private val REQUESTCODE = ... Read More

How to use Volley Library to parse JSON in Android Kotlin App?

Azhar
Updated on 21-Apr-2020 09:23:28

2K+ Views

This example demonstrates how to use Volley Library to parse JSON 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.             Step 3 − Add the following dependency to the build.gradle file−implementation 'com.android.volley:volley:1.1.0'Step 4 − Add the following code to MainActivity.ktimport android.os.Bundle import android.widget.Button import android.widget.TextView import androidx.appcompat.app.AppCompatActivity import com.android.volley.Request import com.android.volley.RequestQueue import com.android.volley.Response import com.android.volley.toolbox.JsonObjectRequest import com.android.volley.toolbox.Volley import org.json.JSONException class MainActivity : AppCompatActivity() {    private lateinit ... Read More

Advertisements