Found 2041 Articles for Mobile Development

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

Azhar
Updated on 23-May-2020 14:05:11

295 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
Updated on 23-May-2020 14:01:50

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
Updated on 23-May-2020 13:58:32

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 obtain the phone number of the Android phone programmatically using Kotlin?

Azhar
Updated on 23-May-2020 13:53:44

2K+ Views

This example demonstrates how to obtain the phone number of the Android phone 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.Example         Step 3 − Add the following code to src/MainActivity.ktExampleimport android.Manifest import android.content.Context import android.content.pm.PackageManager import android.os.Bundle import android.telephony.TelephonyManager import android.widget.TextView import android.widget.Toast import androidx.appcompat.app.AppCompatActivity import androidx.core.app.ActivityCompat class MainActivity : AppCompatActivity() {    private lateinit var textView: TextView    private val permission = 101    override fun onCreate(savedInstanceState: ... Read More

How to check Android Phone Model programmatically using Kotlin?

Azhar
Updated on 23-May-2020 13:50:05

878 Views

This example demonstrates how to check Android Phone Model 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.Example             Step 3 − Add the following code to src/MainActivity.ktExampleimport android.os.Build import android.os.Bundle import android.view.View 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"   ... Read More

How to get the Touch position on an android device using kotlin?

Azhar
Updated on 23-May-2020 13:46:42

451 Views

This example demonstrates how to get the Touch position on an android device 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.EditText import android.widget.TextView import androidx.appcompat.app.AppCompatActivity class MainActivity : AppCompatActivity() {    lateinit var textView: TextView    lateinit var editTextX: EditText    lateinit var editTextY: EditText    override fun onCreate(savedInstanceState: Bundle?) {       super.onCreate(savedInstanceState) ... Read More

How can I define underlined text in an Android layout xml file using Kotlin?

Azhar
Updated on 23-May-2020 13:43:19

865 Views

This example demonstrates how to define underlined text in an Android layout xml file 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.graphics.Color import android.os.Bundle import android.text.SpannableString import android.text.style.UnderlineSpan import android.widget.TextView import androidx.appcompat.app.AppCompatActivity class MainActivity : AppCompatActivity() {    private val string = "This is an underlined textView!"    lateinit var textView: TextView    override fun onCreate(savedInstanceState: Bundle?) { ... Read More

How to request Location Permission at runtime on Kotlin?

Azhar
Updated on 23-May-2020 13:38:23

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

How to change the background color of ListView items on Android Kotlin?

Azhar
Updated on 23-May-2020 13:33:20

847 Views

This example demonstrates how to change the background color of ListView items 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.Example     Step 3 − Add the following code to src/MainActivity.ktExampleimport android.graphics.Color import android.os.Build import android.os.Bundle import android.widget.* import android.widget.AdapterView.OnItemClickListener import androidx.appcompat.app.AppCompatActivity class MainActivity : AppCompatActivity() {    var list = arrayOf(       "Android", "IPhone", "WindowsMobile", "Blackberry",       "WebOS", "Ubuntu", "Windows7", "Max OS X"    )    override ... Read More

How to add new contacts in Android App using Kotlin?

Azhar
Updated on 23-May-2020 13:28:28

823 Views

This example demonstrates how to determine if network type (2G, 3G or 4G) in 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.Example                     Step 3 − Add the following code to src/MainActivity.ktExampleimport android.app.Activity import android.content.Intent import android.os.Bundle import android.provider.ContactsContract import android.view.View import android.widget.EditText import android.widget.Toast import androidx.appcompat.app.AppCompatActivity class MainActivity : AppCompatActivity() {    override fun onCreate(savedInstanceState: Bundle?) {       super.onCreate(savedInstanceState)     ... Read More

Advertisements