Found 1952 Articles for Apps/Applications

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

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

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

How to determine if network type (2G, 3G or 4G) in Android Kotlin?

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

502 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 4 − Add the following code to src/MainActivity.ktExampleimport android.content.Context import android.os.Bundle import android.telephony.TelephonyManager import android.widget.Toast import androidx.appcompat.app.AppCompatActivity import java.util.* class MainActivity : AppCompatActivity() {    override fun onCreate(savedInstanceState: Bundle?) {       super.onCreate(savedInstanceState)       setContentView(R.layout.activity_main)       title = "KotlinApp"       ... Read More

How to display animated GIF images in Android using Kotlin?

Azhar
Updated on 23-May-2020 13:16:56

4K+ Views

This example demonstrates how to display animated GIF images 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 dependency in build.gradle (module:app)implementation 'com.github.bumptech.glide:glide:4.9.0'Step 3 − Add the following code to res/layout/activity_main.xml.Example         Step 4 − Add the following code to src/MainActivity.ktExampleimport android.os.Bundle import android.view.View import android.widget.ImageView import androidx.appcompat.app.AppCompatActivity import com.bumptech.glide.Glide class MainActivity : AppCompatActivity() {    override fun onCreate(savedInstanceState: Bundle?) {       super.onCreate(savedInstanceState)       setContentView(R.layout.activity_main)       ... Read More

How to call a method after a delay in Android Kotlin?

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

873 Views

This example demonstrates how to call a method after a delay 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.os.Bundle import android.os.Handler import android.widget.TextView import android.widget.Toast import androidx.appcompat.app.AppCompatActivity class MainActivity : AppCompatActivity() {    lateinit var textView: TextView    private val string = "Delay by 5 seconds"    override fun onCreate(savedInstanceState: Bundle?) {       super.onCreate(savedInstanceState) ... Read More

How can I save a HashMap to Sharedpreferences in Android Kotlin?

Azhar
Updated on 23-May-2020 13:08:29

1K+ Views

This example demonstrates how to save a HashMap to Sharedpreferences 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.content.Context import android.content.SharedPreferences import android.os.Bundle import android.view.View import android.widget.EditText import android.widget.TextView import android.widget.Toast import androidx.appcompat.app.AppCompatActivity import org.json.JSONObject import java.util.* import kotlin.collections.HashMap class MainActivity : AppCompatActivity() {    private val mapKey = "map"    lateinit ... Read More

How to get a working vertical SeekBar in Android using Kotlin?

Azhar
Updated on 23-May-2020 12:49:51

496 Views

This example demonstrates how to listen for volume buttons in Android background service 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.SeekBar import android.widget.SeekBar.OnSeekBarChangeListener import android.widget.TextView import androidx.appcompat.app.AppCompatActivity class MainActivity : AppCompatActivity() {    lateinit var seekBar: SeekBar    lateinit var textView: TextView    var min = 0    var max: Int = 100    var current: Int ... Read More

How to use BroadcastReceiver in Kotlin?

Azhar
Updated on 23-May-2020 12:45:54

4K+ Views

This example demonstrates how to use BroadcastReceiver 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.content.BroadcastReceiver import android.content.Context import android.content.Intent import android.content.IntentFilter import android.net.wifi.WifiManager import android.os.Bundle import android.widget.Switch import android.widget.Toast import androidx.appcompat.app.AppCompatActivity class MainActivity : AppCompatActivity() {    lateinit var wifiSwitch: Switch    lateinit var wifiManager: WifiManager    override fun onCreate(savedInstanceState: Bundle?) {       super.onCreate(savedInstanceState)     ... Read More

How to pass an arrayList to another activity using intents in Android Kotlin?

Azhar
Updated on 23-May-2020 12:39:06

4K+ Views

This example demonstrates how to pass an arrayList to another activity using intents 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.content.Intent import android.os.Bundle import android.widget.Button import androidx.appcompat.app.AppCompatActivity class MainActivity : AppCompatActivity() {    lateinit var button: Button    var numbers: ArrayList = ArrayList()    override fun onCreate(savedInstanceState: Bundle?) {       super.onCreate(savedInstanceState)     ... Read More

Advertisements