Found 1952 Articles for Apps/Applications

How to check if an Android application is running in the background using Kotlin?

Azhar
Updated on 28-Nov-2020 12:39:57

2K+ Views

This example demonstrates how to check if an Android application is running in the background 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.ActivityManager import android.app.ActivityManager.RunningAppProcessInfo import android.os.Bundle import android.widget.Toast import androidx.appcompat.app.AppCompatActivity class MainActivity : AppCompatActivity() {    var appRunningBackground: Boolean = false    override fun onCreate(savedInstanceState: Bundle?) {       super.onCreate(savedInstanceState)       setContentView(R.layout.activity_main)     ... Read More

How to start a new activity by clicking a button on Android using Kotlin?

Azhar
Updated on 28-Nov-2020 12:30:51

3K+ Views

This example demonstrates how to start new activity on click button on 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 androidx.appcompat.app.AppCompatActivity import android.os.Bundle import android.widget.Button class MainActivity : AppCompatActivity() {    override fun onCreate(savedInstanceState: Bundle?) {       super.onCreate(savedInstanceState)       setContentView(R.layout.activity_main)       val button: Button = findViewById(R.id.button)       button.setOnClickListener ... Read More

Android bundle to pass data between activities using Kotlin.

Azhar
Updated on 28-Nov-2020 12:26:45

3K+ Views

This example demonstrates how to pass data between activities 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.Intent import android.os.Bundle import android.text.TextUtils import android.widget.Button import android.widget.EditText import android.widget.Toast import androidx.appcompat.app.AppCompatActivity import java.io.Serializable class MainActivity : AppCompatActivity() {    lateinit var etName: EditText    lateinit var etPhone: EditText    override fun onCreate(savedInstanceState: Bundle?) {       super.onCreate(savedInstanceState) ... Read More

Custom Progress Bar in Android using Kotlin.

Azhar
Updated on 28-Nov-2020 12:14:10

2K+ Views

This example demonstrates how to create a custom Progress Bar 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.ProgressBar class MainActivity : AppCompatActivity() {    lateinit var progressBar:ProgressBar    override fun onCreate(savedInstanceState: Bundle?) {       super.onCreate(savedInstanceState)       setContentView(R.layout.activity_main)       title = "KotlinApp"       progressBar = ... Read More

How to make an Android Spinner with initial default text using Kotlin?

Azhar
Updated on 28-Nov-2020 12:11:03

1K+ Views

This example demonstrates how to make an Android Spinner with initial default text 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.view.View import android.widget.AdapterView import android.widget.AdapterView.OnItemSelectedListener import android.widget.ArrayAdapter import android.widget.Spinner import android.widget.Toast import androidx.appcompat.app.AppCompatActivity class MainActivity : AppCompatActivity() {    lateinit var spinner: Spinner    override fun onCreate(savedInstanceState: Bundle?) {       super.onCreate(savedInstanceState)   ... Read More

How to use Alarm Manager in Android?

Azhar
Updated on 29-Sep-2020 12:10:48

289 Views

This example demonstrates how to use AlarmManager in Android.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.AlarmManager import android.app.PendingIntent import android.content.BroadcastReceiver import android.content.Context import android.content.Intent import android.os.Build import android.os.Bundle import android.util.Log import android.widget.Button import android.widget.TimePicker import android.widget.Toast import androidx.appcompat.app.AppCompatActivity import java.util.* class MainActivity : AppCompatActivity() {    lateinit var btnSetAlarm: Button lateinit    var timePicker: TimePicker    override fun ... Read More

How do I send an object from one Android Activity to another using Intents in Kotlin?

Azhar
Updated on 28-Nov-2020 11:58:05

571 Views

This example demonstrates how to send an object from one Android Activity to another using Intents 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 src/MainActivity.ktimport android.content.Intent import android.os.Bundle import android.widget.Button import android.widget.EditText import androidx.appcompat.app.AppCompatActivity import java.io.Serializable class MainActivity : AppCompatActivity() {    lateinit var editText: EditText    lateinit var button: Button    override fun onCreate(savedInstanceState: Bundle?) {     ... Read More

How to check internet connection availability and the network type on Android using Kotlin?

Azhar
Updated on 28-Nov-2020 11:49:26

1K+ Views

This example demonstrates how to check internet connection availability and the network type on 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.content.Context import android.net.ConnectivityManager import android.os.Bundle 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)       setContentView(R.layout.activity_main)   ... Read More

How do I load an ImageView by URL on Android using kotlin?

Azhar
Updated on 28-Nov-2020 11:43:48

4K+ Views

This example demonstrates how to load an ImageView by URL on 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.annotation.SuppressLint import android.graphics.Bitmap import android.graphics.BitmapFactory import android.os.AsyncTask import androidx.appcompat.app.AppCompatActivity import android.os.Bundle import android.util.Log import android.widget.ImageView import android.widget.Toast class MainActivity : AppCompatActivity() {    override fun onCreate(savedInstanceState: Bundle?) {       super.onCreate(savedInstanceState)       setContentView(R.layout.activity_main)       ... Read More

How do I pass an object from one activity to another on Android using Kotlin?

Azhar
Updated on 28-Nov-2020 11:37:54

2K+ Views

This example demonstrates how to pass an object from one activity to another on 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.content.Intent import android.os.Bundle import android.widget.Button import androidx.appcompat.app.AppCompatActivity import java.io.Serializable; class MainActivity : AppCompatActivity() {    override fun onCreate(savedInstanceState: Bundle?) {       super.onCreate(savedInstanceState)       setContentView(R.layout.activity_main)       title = "KotlinApp"     ... Read More

Advertisements